Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-19 14:30:17 +01:00
Use Mojang mappings for Geyser-Fabric
Dieser Commit ist enthalten in:
Ursprung
0e07991edf
Commit
144d7b000a
1
Jenkinsfile
vendored
1
Jenkinsfile
vendored
@ -101,7 +101,6 @@ pipeline {
|
|||||||
success {
|
success {
|
||||||
script {
|
script {
|
||||||
if (env.BRANCH_NAME == 'master') {
|
if (env.BRANCH_NAME == 'master') {
|
||||||
build propagate: false, wait: false, job: 'GeyserMC/Geyser-Fabric/master', parameters: [booleanParam(name: 'SKIP_DISCORD', value: true)]
|
|
||||||
build propagate: false, wait: false, job: 'GeyserMC/GeyserConnect/master', parameters: [booleanParam(name: 'SKIP_DISCORD', value: true)]
|
build propagate: false, wait: false, job: 'GeyserMC/GeyserConnect/master', parameters: [booleanParam(name: 'SKIP_DISCORD', value: true)]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ java {
|
|||||||
dependencies {
|
dependencies {
|
||||||
//to change the versions see the gradle.properties file
|
//to change the versions see the gradle.properties file
|
||||||
minecraft(libs.fabric.minecraft)
|
minecraft(libs.fabric.minecraft)
|
||||||
mappings(libs.fabric.yarn) { artifact { classifier = "v2" } }
|
mappings(loom.officialMojangMappings())
|
||||||
modImplementation(libs.fabric.loader)
|
modImplementation(libs.fabric.loader)
|
||||||
|
|
||||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||||
|
@ -54,12 +54,12 @@ public class GeyserFabricDumpInfo extends BootstrapDumpInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.environmentType = FabricLoader.getInstance().getEnvironmentType();
|
this.environmentType = FabricLoader.getInstance().getEnvironmentType();
|
||||||
if (AsteriskSerializer.showSensitive || (server.getServerIp() == null || server.getServerIp().equals("") || server.getServerIp().equals("0.0.0.0"))) {
|
if (AsteriskSerializer.showSensitive || (server.getLocalIp() == null || server.getLocalIp().equals("") || server.getLocalIp().equals("0.0.0.0"))) {
|
||||||
this.serverIP = server.getServerIp();
|
this.serverIP = server.getLocalIp();
|
||||||
} else {
|
} else {
|
||||||
this.serverIP = "***";
|
this.serverIP = "***";
|
||||||
}
|
}
|
||||||
this.serverPort = server.getServerPort();
|
this.serverPort = server.getPort();
|
||||||
this.mods = new ArrayList<>();
|
this.mods = new ArrayList<>();
|
||||||
|
|
||||||
for (ModContainer mod : FabricLoader.getInstance().getAllMods()) {
|
for (ModContainer mod : FabricLoader.getInstance().getAllMods()) {
|
||||||
|
@ -31,27 +31,28 @@ import net.fabricmc.api.ModInitializer;
|
|||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
import net.fabricmc.loader.api.ModContainer;
|
import net.fabricmc.loader.api.ModContainer;
|
||||||
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
|
import net.minecraft.commands.Commands;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.geysermc.common.PlatformType;
|
import org.geysermc.common.PlatformType;
|
||||||
|
import org.geysermc.geyser.GeyserBootstrap;
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
import org.geysermc.geyser.GeyserLogger;
|
import org.geysermc.geyser.GeyserLogger;
|
||||||
import org.geysermc.geyser.api.command.Command;
|
import org.geysermc.geyser.api.command.Command;
|
||||||
import org.geysermc.geyser.api.network.AuthType;
|
import org.geysermc.geyser.api.network.AuthType;
|
||||||
import org.geysermc.geyser.command.GeyserCommand;
|
import org.geysermc.geyser.command.GeyserCommand;
|
||||||
import org.geysermc.geyser.command.GeyserCommandManager;
|
import org.geysermc.geyser.command.GeyserCommandManager;
|
||||||
import org.geysermc.geyser.dump.BootstrapDumpInfo;
|
|
||||||
import org.geysermc.geyser.ping.GeyserLegacyPingPassthrough;
|
|
||||||
import org.geysermc.geyser.text.GeyserLocale;
|
|
||||||
import org.geysermc.geyser.GeyserBootstrap;
|
|
||||||
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
||||||
|
import org.geysermc.geyser.dump.BootstrapDumpInfo;
|
||||||
import org.geysermc.geyser.level.WorldManager;
|
import org.geysermc.geyser.level.WorldManager;
|
||||||
|
import org.geysermc.geyser.ping.GeyserLegacyPingPassthrough;
|
||||||
import org.geysermc.geyser.ping.IGeyserPingPassthrough;
|
import org.geysermc.geyser.ping.IGeyserPingPassthrough;
|
||||||
import org.geysermc.geyser.util.FileUtils;
|
|
||||||
import org.geysermc.geyser.platform.fabric.command.GeyserFabricCommandExecutor;
|
import org.geysermc.geyser.platform.fabric.command.GeyserFabricCommandExecutor;
|
||||||
import org.geysermc.geyser.platform.fabric.command.GeyserFabricCommandManager;
|
import org.geysermc.geyser.platform.fabric.command.GeyserFabricCommandManager;
|
||||||
import org.geysermc.geyser.platform.fabric.world.GeyserFabricWorldManager;
|
import org.geysermc.geyser.platform.fabric.world.GeyserFabricWorldManager;
|
||||||
|
import org.geysermc.geyser.text.GeyserLocale;
|
||||||
|
import org.geysermc.geyser.util.FileUtils;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -145,7 +146,7 @@ public class GeyserFabricMod implements ModInitializer, GeyserBootstrap {
|
|||||||
|
|
||||||
if (this.geyserConfig.getRemote().address().equalsIgnoreCase("auto")) {
|
if (this.geyserConfig.getRemote().address().equalsIgnoreCase("auto")) {
|
||||||
this.geyserConfig.setAutoconfiguredRemote(true);
|
this.geyserConfig.setAutoconfiguredRemote(true);
|
||||||
String ip = server.getServerIp();
|
String ip = server.getLocalIp();
|
||||||
int port = ((GeyserServerPortGetter) server).geyser$getServerPort();
|
int port = ((GeyserServerPortGetter) server).geyser$getServerPort();
|
||||||
if (ip != null && !ip.isEmpty() && !ip.equals("0.0.0.0")) {
|
if (ip != null && !ip.isEmpty() && !ip.equals("0.0.0.0")) {
|
||||||
this.geyserConfig.getRemote().setAddress(ip);
|
this.geyserConfig.getRemote().setAddress(ip);
|
||||||
@ -185,16 +186,16 @@ public class GeyserFabricMod implements ModInitializer, GeyserBootstrap {
|
|||||||
GeyserFabricCommandExecutor helpExecutor = new GeyserFabricCommandExecutor(connector,
|
GeyserFabricCommandExecutor helpExecutor = new GeyserFabricCommandExecutor(connector,
|
||||||
(GeyserCommand) connector.commandManager().getCommands().get("help"), !playerCommands.contains("help"));
|
(GeyserCommand) connector.commandManager().getCommands().get("help"), !playerCommands.contains("help"));
|
||||||
commandExecutors.add(helpExecutor);
|
commandExecutors.add(helpExecutor);
|
||||||
LiteralArgumentBuilder<ServerCommandSource> builder = net.minecraft.server.command.CommandManager.literal("geyser").executes(helpExecutor);
|
LiteralArgumentBuilder<CommandSourceStack> builder = Commands.literal("geyser").executes(helpExecutor);
|
||||||
|
|
||||||
// Register all subcommands as valid
|
// Register all subcommands as valid
|
||||||
for (Map.Entry<String, Command> command : connector.commandManager().getCommands().entrySet()) {
|
for (Map.Entry<String, Command> command : connector.commandManager().getCommands().entrySet()) {
|
||||||
GeyserFabricCommandExecutor executor = new GeyserFabricCommandExecutor(connector, (GeyserCommand) command.getValue(),
|
GeyserFabricCommandExecutor executor = new GeyserFabricCommandExecutor(connector, (GeyserCommand) command.getValue(),
|
||||||
!playerCommands.contains(command.getKey()));
|
!playerCommands.contains(command.getKey()));
|
||||||
commandExecutors.add(executor);
|
commandExecutors.add(executor);
|
||||||
builder.then(net.minecraft.server.command.CommandManager.literal(command.getKey()).executes(executor));
|
builder.then(Commands.literal(command.getKey()).executes(executor));
|
||||||
}
|
}
|
||||||
server.getCommandManager().getDispatcher().register(builder);
|
server.getCommands().getDispatcher().register(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -245,7 +246,7 @@ public class GeyserFabricMod implements ModInitializer, GeyserBootstrap {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMinecraftServerVersion() {
|
public String getMinecraftServerVersion() {
|
||||||
return this.server.getVersion();
|
return this.server.getServerVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -39,7 +39,7 @@ public interface GeyserServerPortGetter {
|
|||||||
* <li>If it's an integrated server, it will return the LAN port if opened, else -1.</li>
|
* <li>If it's an integrated server, it will return the LAN port if opened, else -1.</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* The reason is that {@link MinecraftServer#getServerPort()} doesn't return the LAN port if it's the integrated server,
|
* The reason is that {@link MinecraftServer#getPort()} doesn't return the LAN port if it's the integrated server,
|
||||||
* and changing the behavior of this method via a mixin should be avoided as it could have unexpected consequences.
|
* and changing the behavior of this method via a mixin should be avoided as it could have unexpected consequences.
|
||||||
*
|
*
|
||||||
* @return The server port.
|
* @return The server port.
|
||||||
|
@ -25,31 +25,33 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.platform.fabric.command;
|
package org.geysermc.geyser.platform.fabric.command;
|
||||||
|
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||||
import org.geysermc.geyser.platform.fabric.GeyserFabricMod;
|
import org.geysermc.geyser.platform.fabric.GeyserFabricMod;
|
||||||
import org.geysermc.geyser.text.ChatColor;
|
import org.geysermc.geyser.text.ChatColor;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class FabricCommandSender implements GeyserCommandSource {
|
public class FabricCommandSender implements GeyserCommandSource {
|
||||||
|
|
||||||
private final ServerCommandSource source;
|
private final CommandSourceStack source;
|
||||||
|
|
||||||
public FabricCommandSender(ServerCommandSource source) {
|
public FabricCommandSender(CommandSourceStack source) {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public String name() {
|
||||||
return source.getName();
|
return source.getTextName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(String message) {
|
public void sendMessage(@Nonnull String message) {
|
||||||
if (source.getEntity() instanceof ServerPlayerEntity) {
|
if (source.getEntity() instanceof ServerPlayer) {
|
||||||
((ServerPlayerEntity) source.getEntity()).sendMessage(Text.literal(message), false);
|
((ServerPlayer) source.getEntity()).displayClientMessage(Component.literal(message), false);
|
||||||
} else {
|
} else {
|
||||||
GeyserImpl.getInstance().getLogger().info(ChatColor.toANSI(message + ChatColor.RESET));
|
GeyserImpl.getInstance().getLogger().info(ChatColor.toANSI(message + ChatColor.RESET));
|
||||||
}
|
}
|
||||||
@ -57,7 +59,7 @@ public class FabricCommandSender implements GeyserCommandSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isConsole() {
|
public boolean isConsole() {
|
||||||
return !(source.getEntity() instanceof ServerPlayerEntity);
|
return !(source.getEntity() instanceof ServerPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,7 +27,7 @@ package org.geysermc.geyser.platform.fabric.command;
|
|||||||
|
|
||||||
import com.mojang.brigadier.Command;
|
import com.mojang.brigadier.Command;
|
||||||
import com.mojang.brigadier.context.CommandContext;
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
import org.geysermc.geyser.command.GeyserCommand;
|
import org.geysermc.geyser.command.GeyserCommand;
|
||||||
import org.geysermc.geyser.command.GeyserCommandExecutor;
|
import org.geysermc.geyser.command.GeyserCommandExecutor;
|
||||||
@ -39,7 +39,7 @@ import org.geysermc.geyser.text.GeyserLocale;
|
|||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
public class GeyserFabricCommandExecutor extends GeyserCommandExecutor implements Command<ServerCommandSource> {
|
public class GeyserFabricCommandExecutor extends GeyserCommandExecutor implements Command<CommandSourceStack> {
|
||||||
|
|
||||||
private final GeyserCommand command;
|
private final GeyserCommand command;
|
||||||
/**
|
/**
|
||||||
@ -59,13 +59,13 @@ public class GeyserFabricCommandExecutor extends GeyserCommandExecutor implement
|
|||||||
* @param source The command source attempting to run the command
|
* @param source The command source attempting to run the command
|
||||||
* @return True if the command source is allowed to
|
* @return True if the command source is allowed to
|
||||||
*/
|
*/
|
||||||
public boolean canRun(ServerCommandSource source) {
|
public boolean canRun(CommandSourceStack source) {
|
||||||
return !requiresPermission() || source.hasPermissionLevel(GeyserFabricPermissions.RESTRICTED_MIN_LEVEL);
|
return !requiresPermission() || source.hasPermission(GeyserFabricPermissions.RESTRICTED_MIN_LEVEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int run(CommandContext context) {
|
public int run(CommandContext context) {
|
||||||
ServerCommandSource source = (ServerCommandSource) context.getSource();
|
CommandSourceStack source = (CommandSourceStack) context.getSource();
|
||||||
FabricCommandSender sender = new FabricCommandSender(source);
|
FabricCommandSender sender = new FabricCommandSender(source);
|
||||||
GeyserSession session = getGeyserSession(sender);
|
GeyserSession session = getGeyserSession(sender);
|
||||||
if (!canRun(source)) {
|
if (!canRun(source)) {
|
||||||
|
@ -27,11 +27,11 @@ package org.geysermc.geyser.platform.fabric.mixin.client;
|
|||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.server.IntegratedServer;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.integrated.IntegratedServer;
|
import net.minecraft.world.level.GameType;
|
||||||
import net.minecraft.text.Text;
|
|
||||||
import net.minecraft.world.GameMode;
|
|
||||||
import org.geysermc.geyser.platform.fabric.GeyserFabricMod;
|
import org.geysermc.geyser.platform.fabric.GeyserFabricMod;
|
||||||
import org.geysermc.geyser.platform.fabric.GeyserServerPortGetter;
|
import org.geysermc.geyser.platform.fabric.GeyserServerPortGetter;
|
||||||
import org.geysermc.geyser.text.GeyserLocale;
|
import org.geysermc.geyser.text.GeyserLocale;
|
||||||
@ -46,25 +46,25 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||||||
@Mixin(IntegratedServer.class)
|
@Mixin(IntegratedServer.class)
|
||||||
public class IntegratedServerMixin implements GeyserServerPortGetter {
|
public class IntegratedServerMixin implements GeyserServerPortGetter {
|
||||||
@Shadow
|
@Shadow
|
||||||
private int lanPort;
|
private int publishedPort;
|
||||||
|
|
||||||
@Shadow @Final private MinecraftClient client;
|
@Shadow @Final private Minecraft minecraft;
|
||||||
|
|
||||||
@Inject(method = "openToLan", at = @At("RETURN"))
|
@Inject(method = "publishServer", at = @At("RETURN"))
|
||||||
private void onOpenToLan(GameMode gameMode, boolean cheatsAllowed, int port, CallbackInfoReturnable<Boolean> cir) {
|
private void onOpenToLan(GameType gameType, boolean cheatsAllowed, int port, CallbackInfoReturnable<Boolean> cir) {
|
||||||
if (cir.getReturnValueZ()) {
|
if (cir.getReturnValueZ()) {
|
||||||
// If the LAN is opened, starts Geyser.
|
// If the LAN is opened, starts Geyser.
|
||||||
GeyserFabricMod.getInstance().startGeyser((MinecraftServer) (Object) this);
|
GeyserFabricMod.getInstance().startGeyser((MinecraftServer) (Object) this);
|
||||||
// Ensure player locale has been loaded, in case it's different from Java system language
|
// Ensure player locale has been loaded, in case it's different from Java system language
|
||||||
GeyserLocale.loadGeyserLocale(this.client.options.language);
|
GeyserLocale.loadGeyserLocale(this.minecraft.options.languageCode);
|
||||||
// Give indication that Geyser is loaded
|
// Give indication that Geyser is loaded
|
||||||
this.client.player.sendMessage(Text.literal(GeyserLocale.getPlayerLocaleString("geyser.core.start",
|
this.minecraft.player.displayClientMessage(Component.literal(GeyserLocale.getPlayerLocaleString("geyser.core.start",
|
||||||
this.client.options.language, "localhost", String.valueOf(this.lanPort))), false);
|
this.minecraft.options.languageCode, "localhost", String.valueOf(this.publishedPort))), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int geyser$getServerPort() {
|
public int geyser$getServerPort() {
|
||||||
return this.lanPort;
|
return this.publishedPort;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,26 +26,26 @@
|
|||||||
package org.geysermc.geyser.platform.fabric.mixin.server;
|
package org.geysermc.geyser.platform.fabric.mixin.server;
|
||||||
|
|
||||||
import com.mojang.datafixers.DataFixer;
|
import com.mojang.datafixers.DataFixer;
|
||||||
import net.minecraft.resource.ResourcePackManager;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.SaveLoader;
|
import net.minecraft.server.Services;
|
||||||
import net.minecraft.server.WorldGenerationProgressListenerFactory;
|
import net.minecraft.server.WorldStem;
|
||||||
import net.minecraft.server.dedicated.MinecraftDedicatedServer;
|
import net.minecraft.server.dedicated.DedicatedServer;
|
||||||
import net.minecraft.util.ApiServices;
|
import net.minecraft.server.level.progress.ChunkProgressListenerFactory;
|
||||||
import net.minecraft.world.level.storage.LevelStorage;
|
import net.minecraft.server.packs.repository.PackRepository;
|
||||||
|
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||||
import org.geysermc.geyser.platform.fabric.GeyserServerPortGetter;
|
import org.geysermc.geyser.platform.fabric.GeyserServerPortGetter;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
import java.net.Proxy;
|
import java.net.Proxy;
|
||||||
|
|
||||||
@Mixin(MinecraftDedicatedServer.class)
|
@Mixin(DedicatedServer.class)
|
||||||
public abstract class MinecraftDedicatedServerMixin extends MinecraftServer implements GeyserServerPortGetter {
|
public abstract class MinecraftDedicatedServerMixin extends MinecraftServer implements GeyserServerPortGetter {
|
||||||
public MinecraftDedicatedServerMixin(Thread serverThread, LevelStorage.Session session, ResourcePackManager dataPackManager, SaveLoader saveLoader, Proxy proxy, DataFixer dataFixer, ApiServices apiServices, WorldGenerationProgressListenerFactory worldGenerationProgressListenerFactory) {
|
public MinecraftDedicatedServerMixin(Thread thread, LevelStorageSource.LevelStorageAccess levelStorageAccess, PackRepository packRepository, WorldStem worldStem, Proxy proxy, DataFixer dataFixer, Services services, ChunkProgressListenerFactory chunkProgressListenerFactory) {
|
||||||
super(serverThread, session, dataPackManager, saveLoader, proxy, dataFixer, apiServices, worldGenerationProgressListenerFactory);
|
super(thread, levelStorageAccess, packRepository, worldStem, proxy, dataFixer, services, chunkProgressListenerFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int geyser$getServerPort() {
|
public int geyser$getServerPort() {
|
||||||
return this.getServerPort();
|
return this.getPort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,15 +29,15 @@ import com.nukkitx.math.vector.Vector3i;
|
|||||||
import com.nukkitx.nbt.NbtMap;
|
import com.nukkitx.nbt.NbtMap;
|
||||||
import com.nukkitx.nbt.NbtMapBuilder;
|
import com.nukkitx.nbt.NbtMapBuilder;
|
||||||
import com.nukkitx.nbt.NbtType;
|
import com.nukkitx.nbt.NbtType;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.block.entity.LecternBlockEntity;
|
import net.minecraft.nbt.ListTag;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.WritableBookItem;
|
|
||||||
import net.minecraft.item.WrittenBookItem;
|
|
||||||
import net.minecraft.nbt.NbtList;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.WritableBookItem;
|
||||||
|
import net.minecraft.world.item.WrittenBookItem;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.entity.LecternBlockEntity;
|
||||||
import org.geysermc.geyser.level.GeyserWorldManager;
|
import org.geysermc.geyser.level.GeyserWorldManager;
|
||||||
import org.geysermc.geyser.platform.fabric.GeyserFabricMod;
|
import org.geysermc.geyser.platform.fabric.GeyserFabricMod;
|
||||||
import org.geysermc.geyser.platform.fabric.command.GeyserFabricCommandExecutor;
|
import org.geysermc.geyser.platform.fabric.command.GeyserFabricCommandExecutor;
|
||||||
@ -65,9 +65,9 @@ public class GeyserFabricWorldManager extends GeyserWorldManager {
|
|||||||
public NbtMap getLecternDataAt(GeyserSession session, int x, int y, int z, boolean isChunkLoad) {
|
public NbtMap getLecternDataAt(GeyserSession session, int x, int y, int z, boolean isChunkLoad) {
|
||||||
Runnable lecternGet = () -> {
|
Runnable lecternGet = () -> {
|
||||||
// Mostly a reimplementation of Spigot lectern support
|
// Mostly a reimplementation of Spigot lectern support
|
||||||
PlayerEntity player = getPlayer(session);
|
ServerPlayer player = getPlayer(session);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
BlockEntity blockEntity = player.world.getBlockEntity(new BlockPos(x, y, z));
|
BlockEntity blockEntity = player.level.getBlockEntity(new BlockPos(x, y, z));
|
||||||
if (!(blockEntity instanceof LecternBlockEntity lectern)) {
|
if (!(blockEntity instanceof LecternBlockEntity lectern)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -83,14 +83,14 @@ public class GeyserFabricWorldManager extends GeyserWorldManager {
|
|||||||
int pageCount = WrittenBookItem.getPageCount(book);
|
int pageCount = WrittenBookItem.getPageCount(book);
|
||||||
boolean hasBookPages = pageCount > 0;
|
boolean hasBookPages = pageCount > 0;
|
||||||
NbtMapBuilder lecternTag = LecternInventoryTranslator.getBaseLecternTag(x, y, z, hasBookPages ? pageCount : 1);
|
NbtMapBuilder lecternTag = LecternInventoryTranslator.getBaseLecternTag(x, y, z, hasBookPages ? pageCount : 1);
|
||||||
lecternTag.putInt("page", lectern.getCurrentPage() / 2);
|
lecternTag.putInt("page", lectern.getPage() / 2);
|
||||||
NbtMapBuilder bookTag = NbtMap.builder()
|
NbtMapBuilder bookTag = NbtMap.builder()
|
||||||
.putByte("Count", (byte) book.getCount())
|
.putByte("Count", (byte) book.getCount())
|
||||||
.putShort("Damage", (short) 0)
|
.putShort("Damage", (short) 0)
|
||||||
.putString("Name", "minecraft:writable_book");
|
.putString("Name", "minecraft:writable_book");
|
||||||
List<NbtMap> pages = new ArrayList<>(hasBookPages ? pageCount : 1);
|
List<NbtMap> pages = new ArrayList<>(hasBookPages ? pageCount : 1);
|
||||||
if (hasBookPages && WritableBookItem.isValid(book.getNbt())) {
|
if (hasBookPages && WritableBookItem.makeSureTagIsValid(book.getTag())) {
|
||||||
NbtList listTag = book.getNbt().getList("pages", 8);
|
ListTag listTag = book.getTag().getList("pages", 8);
|
||||||
|
|
||||||
for (int i = 0; i < listTag.size(); i++) {
|
for (int i = 0; i < listTag.size(); i++) {
|
||||||
String page = listTag.getString(i);
|
String page = listTag.getString(i);
|
||||||
@ -127,14 +127,14 @@ public class GeyserFabricWorldManager extends GeyserWorldManager {
|
|||||||
// Workaround for our commands because fabric doesn't have native permissions
|
// Workaround for our commands because fabric doesn't have native permissions
|
||||||
for (GeyserFabricCommandExecutor executor : GeyserFabricMod.getInstance().getCommandExecutors()) {
|
for (GeyserFabricCommandExecutor executor : GeyserFabricMod.getInstance().getCommandExecutors()) {
|
||||||
if (executor.getCommand().permission().equals(permission)) {
|
if (executor.getCommand().permission().equals(permission)) {
|
||||||
return executor.canRun(getPlayer(session).getCommandSource());
|
return executor.canRun(getPlayer(session).createCommandSourceStack());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlayerEntity getPlayer(GeyserSession session) {
|
private ServerPlayer getPlayer(GeyserSession session) {
|
||||||
return server.getPlayerManager().getPlayer(session.getPlayerEntity().getUuid());
|
return server.getPlayerList().getPlayer(session.getPlayerEntity().getUuid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,6 @@ paper-mojangapi = { group = "io.papermc.paper", name = "paper-mojangapi", versio
|
|||||||
|
|
||||||
# check these on https://modmuss50.me/fabric.html
|
# check these on https://modmuss50.me/fabric.html
|
||||||
fabric-minecraft = { group = "com.mojang", name = "minecraft", version = "1.19.1" }
|
fabric-minecraft = { group = "com.mojang", name = "minecraft", version = "1.19.1" }
|
||||||
fabric-yarn = { group = "net.fabricmc", name = "yarn", version = "1.19.1+build.1" }
|
|
||||||
fabric-loader = { group = "net.fabricmc", name = "fabric-loader", version = "0.14.8" }
|
fabric-loader = { group = "net.fabricmc", name = "fabric-loader", version = "0.14.8" }
|
||||||
fabric-api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version = "0.58.5+1.19.1" }
|
fabric-api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version = "0.58.5+1.19.1" }
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren