From ae5f006afe45c0304c2a55c7e8ce2ed590dd0c12 Mon Sep 17 00:00:00 2001 From: eaglercraft Date: Wed, 6 Mar 2024 19:01:47 -0800 Subject: [PATCH] u25 --- build.gradle | 2 +- .../eaglercraft/v1_8/EaglercraftVersion.java | 6 +++--- .../server/EaglerIntegratedServerWorker.java | 6 +++++- .../net/minecraft/client/gui/GuiOptions.java | 1 + .../server/S41PacketServerDifficulty.java | 6 ++++-- .../net/minecraft/server/MinecraftServer.java | 19 +++++++++++++++---- 6 files changed, 29 insertions(+), 11 deletions(-) diff --git a/build.gradle b/build.gradle index 80fc672..5c76755 100755 --- a/build.gradle +++ b/build.gradle @@ -26,7 +26,7 @@ teavm.js { obfuscated = true sourceMap = true targetFileName = "../classes.js" - optimization = org.teavm.gradle.api.OptimizationLevel.AGGRESSIVE + optimization = org.teavm.gradle.api.OptimizationLevel.BALANCED // no fps boost was observed with "AGGRESSIVE" outOfProcess = false fastGlobalAnalysis = false processMemory = 512 diff --git a/src/main/java/net/lax1dude/eaglercraft/v1_8/EaglercraftVersion.java b/src/main/java/net/lax1dude/eaglercraft/v1_8/EaglercraftVersion.java index 4a4b000..30f1d4c 100755 --- a/src/main/java/net/lax1dude/eaglercraft/v1_8/EaglercraftVersion.java +++ b/src/main/java/net/lax1dude/eaglercraft/v1_8/EaglercraftVersion.java @@ -10,7 +10,7 @@ public class EaglercraftVersion { /// Customize these to fit your fork: public static final String projectForkName = "EaglercraftX"; - public static final String projectForkVersion = "u24"; + public static final String projectForkVersion = "u25"; public static final String projectForkVendor = "lax1dude"; public static final String projectForkURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8"; @@ -20,7 +20,7 @@ public class EaglercraftVersion { public static final String projectOriginName = "EaglercraftX"; public static final String projectOriginAuthor = "lax1dude"; public static final String projectOriginRevision = "1.8"; - public static final String projectOriginVersion = "u24"; + public static final String projectOriginVersion = "u25"; public static final String projectOriginURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8"; // rest in peace @@ -31,7 +31,7 @@ public class EaglercraftVersion { public static final boolean enableUpdateService = true; public static final String updateBundlePackageName = "net.lax1dude.eaglercraft.v1_8.client"; - public static final int updateBundlePackageVersionInt = 24; + public static final int updateBundlePackageVersionInt = 25; public static final String updateLatestLocalStorageKey = "latestUpdate_" + updateBundlePackageName; diff --git a/src/main/java/net/lax1dude/eaglercraft/v1_8/sp/server/EaglerIntegratedServerWorker.java b/src/main/java/net/lax1dude/eaglercraft/v1_8/sp/server/EaglerIntegratedServerWorker.java index 3d55e43..a5ec595 100755 --- a/src/main/java/net/lax1dude/eaglercraft/v1_8/sp/server/EaglerIntegratedServerWorker.java +++ b/src/main/java/net/lax1dude/eaglercraft/v1_8/sp/server/EaglerIntegratedServerWorker.java @@ -257,7 +257,11 @@ public class EaglerIntegratedServerWorker { case IPCPacket0ASetWorldDifficulty.ID: { IPCPacket0ASetWorldDifficulty pkt = (IPCPacket0ASetWorldDifficulty)ipc; if(!isServerStopped()) { - currentProcess.setDifficultyForAllWorlds(EnumDifficulty.getDifficultyEnum(pkt.difficulty)); + if(pkt.difficulty == (byte)-1) { + currentProcess.setDifficultyLockedForAllWorlds(true); + }else { + currentProcess.setDifficultyForAllWorlds(EnumDifficulty.getDifficultyEnum(pkt.difficulty)); + } }else { logger.warn("Client tried to set difficulty while server was stopped"); } diff --git a/src/main/java/net/minecraft/client/gui/GuiOptions.java b/src/main/java/net/minecraft/client/gui/GuiOptions.java index 6745e57..b020d50 100755 --- a/src/main/java/net/minecraft/client/gui/GuiOptions.java +++ b/src/main/java/net/minecraft/client/gui/GuiOptions.java @@ -140,6 +140,7 @@ public class GuiOptions extends GuiScreen implements GuiYesNoCallback { this.mc.displayGuiScreen(this); if (i == 109 && flag && this.mc.theWorld != null) { this.mc.theWorld.getWorldInfo().setDifficultyLocked(true); + SingleplayerServerController.setDifficulty(-1); this.field_175356_r.func_175229_b(true); this.field_175356_r.enabled = false; this.field_175357_i.enabled = false; diff --git a/src/main/java/net/minecraft/network/play/server/S41PacketServerDifficulty.java b/src/main/java/net/minecraft/network/play/server/S41PacketServerDifficulty.java index 4cd795d..45dceca 100755 --- a/src/main/java/net/minecraft/network/play/server/S41PacketServerDifficulty.java +++ b/src/main/java/net/minecraft/network/play/server/S41PacketServerDifficulty.java @@ -50,14 +50,16 @@ public class S41PacketServerDifficulty implements Packet * Reads the raw packet data from the data stream. */ public void readPacketData(PacketBuffer parPacketBuffer) throws IOException { - this.difficulty = EnumDifficulty.getDifficultyEnum(parPacketBuffer.readUnsignedByte()); + int i = parPacketBuffer.readUnsignedByte(); + this.difficulty = EnumDifficulty.getDifficultyEnum(i & 3); + this.difficultyLocked = (i & 4) != 0; } /**+ * Writes the raw packet data to the data stream. */ public void writePacketData(PacketBuffer parPacketBuffer) throws IOException { - parPacketBuffer.writeByte(this.difficulty.getDifficultyId()); + parPacketBuffer.writeByte(this.difficulty.getDifficultyId() | (this.difficultyLocked ? 4 : 0)); } public boolean isDifficultyLocked() { diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index cc2ea94..521e5c0 100755 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -23,6 +23,7 @@ import net.minecraft.crash.CrashReport; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.play.server.S03PacketTimeUpdate; +import net.minecraft.network.play.server.S41PacketServerDifficulty; import net.minecraft.profiler.Profiler; import net.minecraft.server.management.ServerConfigurationManager; import net.minecraft.util.BlockPos; @@ -194,13 +195,12 @@ public abstract class MinecraftServer implements Runnable, ICommandSender, IThre } this.worldServers[j].addWorldAccess(new WorldManager(this, this.worldServers[j])); - if (!this.isSinglePlayer()) { - this.worldServers[j].getWorldInfo().setGameType(this.getGameType()); - } } this.serverConfigManager.setPlayerManager(this.worldServers); - this.setDifficultyForAllWorlds(this.getDifficulty()); + if (this.worldServers[0].getWorldInfo().getDifficulty() == null) { + this.setDifficultyForAllWorlds(this.getDifficulty()); + } this.isSpawnChunksLoaded = this.worldServers[0].getWorldInfo().getGameRulesInstance() .getBoolean("loadSpawnChunks"); if (this.isSpawnChunksLoaded) { @@ -756,6 +756,17 @@ public abstract class MinecraftServer implements Runnable, ICommandSender, IThre } } } + this.getConfigurationManager().sendPacketToAllPlayers(new S41PacketServerDifficulty( + this.worldServers[0].getDifficulty(), this.worldServers[0].getWorldInfo().isDifficultyLocked())); + } + + public void setDifficultyLockedForAllWorlds(boolean locked) { + for (int i = 0; i < this.worldServers.length; ++i) { + WorldServer worldserver = this.worldServers[i]; + if (worldserver != null) { + worldserver.getWorldInfo().setDifficultyLocked(locked); + } + } }