diff --git a/patches/server/0010-Optimize-default-configurations.patch b/patches/server/0010-Optimize-default-configurations.patch index 022c4e9fa..0c00d66ca 100644 --- a/patches/server/0010-Optimize-default-configurations.patch +++ b/patches/server/0010-Optimize-default-configurations.patch @@ -9,7 +9,7 @@ Subject: [PATCH] Optimize default configurations - YouHaveTrouble/minecraft-exploits-and-how-to-fix-them diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java -index 9ca1494497ae53e56b1f81fda51b0b8bd02a6d03..ccd7b964aa149482a129c8a45378c38db07b984e 100644 +index 9ca1494497ae53e56b1f81fda51b0b8bd02a6d03..97b1366d25537d68469e95ac101b1b8cf9fdc997 100644 --- a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java +++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java @@ -64,7 +64,7 @@ public class PufferfishConfig { @@ -48,8 +48,27 @@ index 9ca1494497ae53e56b1f81fda51b0b8bd02a6d03..ccd7b964aa149482a129c8a45378c38d "This value defines how much distance modifies an entity's", "tick frequency. freq = (distanceToPlayer^2) / (2^value)", "If you want further away entities to tick less often, use 7.", +@@ -253,8 +253,18 @@ public class PufferfishConfig { + public static Map projectileTimeouts; + private static void projectileTimeouts() { + // Set some defaults ++ // Plazma start - Optimize default configurations ++ if (org.plazmamc.plazma.configurations.PlazmaConfigurations.optimize()) { ++ getInt("entity_timeouts.ARROW", 200); ++ getInt("entity_timeouts.EGG", 200); ++ getInt("entity_timeouts.ENDER_PEARL", 200); ++ getInt("entity_timeouts.SNOWBALL", 200); ++ getInt("entity_timeouts.LLAMA_SPIT", 200); ++ } else { ++ // Plazma end + getInt("entity_timeouts.SNOWBALL", -1); + getInt("entity_timeouts.LLAMA_SPIT", -1); ++ } // Plazma + setComment("entity_timeouts", + "These values define a entity's maximum lifespan. If an", + "entity is in this list and it has survived for longer than", diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java -index a6f58b3457b7477015c5c6d969e7d83017dd3fa1..28acc9a7f9defdddb2d5c28e2d1e45986636a725 100644 +index a6f58b3457b7477015c5c6d969e7d83017dd3fa1..85e56d726eb7780811e0a990e1ef7d3ec767e36d 100644 --- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java +++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java @@ -155,7 +155,7 @@ public class GlobalConfiguration extends ConfigurationPart { @@ -61,8 +80,52 @@ index a6f58b3457b7477015c5c6d969e7d83017dd3fa1..28acc9a7f9defdddb2d5c28e2d1e4598 } public SpamLimiter spamLimiter; +@@ -193,7 +193,7 @@ public class GlobalConfiguration extends ConfigurationPart { + public Commands commands; + + public class Commands extends ConfigurationPart { +- public boolean suggestPlayerNamesWhenNullTabCompletions = true; ++ public boolean suggestPlayerNamesWhenNullTabCompletions = !org.plazmamc.plazma.configurations.PlazmaConfigurations.optimize(); // Plazma - Optimize default configurations + public boolean fixTargetSelectorTagCompletion = true; + public boolean timeCommandAffectsAllWorlds = false; + } +@@ -242,7 +242,7 @@ public class GlobalConfiguration extends ConfigurationPart { + public BookSize bookSize; + + public class BookSize extends ConfigurationPart { +- public int pageMax = 2560; // TODO this appears to be a duplicate setting with one above ++ public int pageMax = org.plazmamc.plazma.configurations.PlazmaConfigurations.optimize() ? 1024 : 2560; // TODO this appears to be a duplicate setting with one above // Plazma - Optimize default configurations + public double totalMultiplier = 0.98D; // TODO this should probably be merged into the above inner class + } + public boolean resolveSelectorsInBooks = false; +@@ -253,7 +253,15 @@ public class GlobalConfiguration extends ConfigurationPart { + public class PacketLimiter extends ConfigurationPart { + public Component kickMessage = Component.translatable("disconnect.exceeded_packet_rate", NamedTextColor.RED); + public PacketLimit allPackets = new PacketLimit(7.0, 500.0, PacketLimit.ViolateAction.KICK); +- public Map>, PacketLimit> overrides = Map.of(ServerboundPlaceRecipePacket.class, new PacketLimit(4.0, 5.0, PacketLimit.ViolateAction.DROP)); ++ // Plazma start - Optimize default configurations ++ public Map>, PacketLimit> overrides = new java.util.HashMap<>() {{ ++ put(ServerboundPlaceRecipePacket.class, new PacketLimit(4.0, 5.0, PacketLimit.ViolateAction.DROP)); ++ if (org.plazmamc.plazma.configurations.PlazmaConfigurations.optimize()) { ++ put(net.minecraft.network.protocol.game.ServerboundCommandSuggestionPacket.class, new PacketLimit(1.0, 15.0, PacketLimit.ViolateAction.DROP)); ++ put(net.minecraft.network.protocol.game.ServerboundPlaceRecipePacket.class, new PacketLimit(4.0, 5.0, PacketLimit.ViolateAction.DROP)); ++ } ++ }}; ++ // Plazma end + + @ConfigSerializable + public record PacketLimit(@Required double interval, @Required double maxPacketRate, ViolateAction action) { +@@ -321,7 +329,7 @@ public class GlobalConfiguration extends ConfigurationPart { + executor.setMaximumPoolSize(_chatExecutorMaxSize); + } + } +- public int maxJoinsPerTick = 5; ++ public int maxJoinsPerTick = org.plazmamc.plazma.configurations.PlazmaConfigurations.optimize() ? 3 : 5; // Plazma - Optimize default configurations + public boolean fixEntityPositionDesync = true; + public boolean loadPermissionsYmlBeforePlugins = true; + @Constraints.Min(4) diff --git a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java -index 071d3877e386a0c7c4d2f2e8ddd06e0765c49d0d..1f0540adf04194407286479b2003005efa111e06 100644 +index 071d3877e386a0c7c4d2f2e8ddd06e0765c49d0d..79e2a6806311c402e481c5b29cbd3ced85101f6e 100644 --- a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java +++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java @@ -96,12 +96,32 @@ public class WorldConfiguration extends ConfigurationPart { @@ -73,7 +136,8 @@ index 071d3877e386a0c7c4d2f2e8ddd06e0765c49d0d..1f0540adf04194407286479b2003005e + public EngineMode engineMode = org.plazmamc.plazma.configurations.PlazmaConfigurations.optimize() ? EngineMode.OBFUSCATE_LAYER : EngineMode.HIDE; // Plazma - Optimize default configurations public int maxBlockHeight = 64; public int updateRadius = 2; - public boolean lavaObscures = false; +- public boolean lavaObscures = false; ++ public boolean lavaObscures = org.plazmamc.plazma.configurations.PlazmaConfigurations.optimize(); // Plazma - Optimize default configurations public boolean usePermission = false; - public List hiddenBlocks = List.of( + // Plazma start - Optimize default configurations @@ -130,6 +194,24 @@ index 071d3877e386a0c7c4d2f2e8ddd06e0765c49d0d..1f0540adf04194407286479b2003005e } } +@@ -152,14 +193,14 @@ public class WorldConfiguration extends ConfigurationPart { + public ArmorStands armorStands; + + public class ArmorStands extends ConfigurationPart { +- public boolean doCollisionEntityLookups = true; +- public boolean tick = true; ++ public boolean doCollisionEntityLookups = !org.plazmamc.plazma.Options.aggressiveOptimize; // Plazma - Optimize default configurations ++ public boolean tick = !org.plazmamc.plazma.Options.aggressiveOptimize; // Plazma - Optimize default configurations + } + + public Markers markers; + + public class Markers extends ConfigurationPart { +- public boolean tick = true; ++ public boolean tick = !org.plazmamc.plazma.configurations.PlazmaConfigurations.optimize(); // Plazma - Optimize default configurations + } + + public Sniffer sniffer; @@ -182,7 +223,7 @@ public class WorldConfiguration extends ConfigurationPart { @MergeMap public Reference2IntMap spawnLimits = Util.make(new Reference2IntOpenHashMap<>(NaturalSpawner.SPAWNING_CATEGORIES.length), map -> Arrays.stream(NaturalSpawner.SPAWNING_CATEGORIES).forEach(mobCategory -> map.put(mobCategory, -1))); @@ -236,7 +318,7 @@ index 071d3877e386a0c7c4d2f2e8ddd06e0765c49d0d..1f0540adf04194407286479b2003005e public class Misc extends ConfigurationPart { public int lightQueueSize = 20; - public boolean updatePathfindingOnBlockUpdate = true; -+ public boolean updatePathfindingOnBlockUpdate = !org.plazmamc.plazma.configurations.PlazmaConfigurations.optimize(); // Plazma - Optimize default configurations ++ public boolean updatePathfindingOnBlockUpdate = !org.plazmamc.plazma.Options.aggressiveOptimize; // Plazma - Optimize default configurations public boolean showSignClickCommandFailureMsgsToPlayer = false; - public RedstoneImplementation redstoneImplementation = RedstoneImplementation.VANILLA; + public RedstoneImplementation redstoneImplementation = org.plazmamc.plazma.configurations.PlazmaConfigurations.optimize() ? RedstoneImplementation.ALTERNATE_CURRENT : RedstoneImplementation.VANILLA; // Plazma - Optimize default configurations @@ -269,21 +351,20 @@ index 5068d942594f19555c6a8f88d49534aba073f722..8afa3ac6f314d0f3def7d19aedceefed File commandFile = (File) optionset.valueOf("commands-settings"); diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java -index cda4544ae96a4fcb5c6c4483df67a59f1b53fd27..a70b614f30be3356c2cde60a5cb28687d3ead34d 100644 +index cda4544ae96a4fcb5c6c4483df67a59f1b53fd27..2282992d04669a705a5b67f616fe921c289182ab 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java -@@ -130,15 +130,15 @@ public class DedicatedServerProperties extends Settings -Date: Fri, 29 Sep 2023 21:10:26 +0900 -Subject: [PATCH] Implement FixMySpawnR +Date: Tue, 5 Dec 2023 13:29:28 +0900 +Subject: [PATCH] Add Entity spawn deadlock timer +[REFERENCE] +- AbsolemJackdaw/FixMySpawnR diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java -index 64d911bee1607880514061c75116d8672df8bb8f..7868590696f620cc5f0785125c9573d7494d8477 100644 +index 914564a528c360f352927e7681ab2e31ed365b21..d05b2cae21b0da18a3a205a239a3c45c93e8b6ef 100644 --- a/src/main/java/net/minecraft/world/level/BaseSpawner.java +++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java @@ -46,6 +46,8 @@ public abstract class BaseSpawner { @@ -14,17 +16,17 @@ index 64d911bee1607880514061c75116d8672df8bb8f..7868590696f620cc5f0785125c9573d7 private int tickDelay = 0; // Paper + private int blockExistsTick = 0; // Plazma - Implement FixMySpawnR + private boolean blockLockedByTime = false; // Plazma - Implement FixMySpawnR - - public BaseSpawner() {} - -@@ -81,6 +83,17 @@ public abstract class BaseSpawner { + // Paper start - ported from 1.20.3 Fix MC-259321 + static net.minecraft.world.level.entity.EntityTypeTest forExactClass(Class clazz) { + return new net.minecraft.world.level.entity.EntityTypeTest<>() { +@@ -97,6 +99,17 @@ public abstract class BaseSpawner { } public void serverTick(ServerLevel world, BlockPos pos) { + // Plazma start - Implement FixMySpawnR -+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().gameMechanics.spawning.deadlockTimer.enabled) { ++ if (world.plazmaConfig().entity.spawnDeadlockTimer.enabled) { + if (!this.blockLockedByTime) { -+ if (this.blockExistsTick > org.plazmamc.plazma.configurations.GlobalConfiguration.get().gameMechanics.spawning.deadlockTimer.timerTimeout) ++ if (this.blockExistsTick > world.plazmaConfig().entity.spawnDeadlockTimer.timerTimeout) + blockLockedByTime = true; + else blockExistsTick++; + } @@ -35,22 +37,20 @@ index 64d911bee1607880514061c75116d8672df8bb8f..7868590696f620cc5f0785125c9573d7 if (spawnCount <= 0 || maxNearbyEntities <= 0) return; // Paper - Ignore impossible spawn tick // Paper start - Configurable mob spawner tick rate if (spawnDelay > 0 && --tickDelay > 0) return; -@@ -286,6 +299,14 @@ public abstract class BaseSpawner { +@@ -301,6 +314,12 @@ public abstract class BaseSpawner { + if (nbt.contains("SpawnRange", 99)) { this.spawnRange = nbt.getShort("SpawnRange"); } - + // Plazma start - Implement FixMySpawnR -+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().gameMechanics.spawning.deadlockTimer.enabled -+ && nbt.contains("Plazma.SpawnerTicks", 99)) { ++ if (world.plazmaConfig().entity.spawnDeadlockTimer.enabled && nbt.contains("Plazma.SpawnerTicks", 99)) { + this.blockExistsTick = nbt.getInt("Plazma.SpawnerTicks"); + this.blockLockedByTime = nbt.getBoolean("Plazma.SpawnerLocked"); + } + // Plazma end -+ + this.displayEntity = null; } - -@@ -314,6 +335,9 @@ public abstract class BaseSpawner { +@@ -330,6 +349,9 @@ public abstract class BaseSpawner { })); } @@ -60,32 +60,22 @@ index 64d911bee1607880514061c75116d8672df8bb8f..7868590696f620cc5f0785125c9573d7 nbt.put("SpawnPotentials", (Tag) SpawnData.LIST_CODEC.encodeStart(NbtOps.INSTANCE, this.spawnPotentials).result().orElseThrow()); return nbt; } -diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -index 989aa0aeb05a878945849adc6fb6663027e15927..d17df5621717b1c8d1d9a5549feb73c3600ecf3d 100644 ---- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -@@ -40,6 +40,24 @@ public class GlobalConfiguration extends ConfigurationPart { +diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java +index b1293935e55fcb1c45224e5bda9be8d1045ff4e8..e5e0b0f0bd3b2249dc1db029682b8957b0addcac 100644 +--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java ++++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java +@@ -54,6 +54,14 @@ public class WorldConfigurations extends ConfigurationPart { - } + } -+ public GameMechanics gameMechanics; -+ public class GameMechanics extends ConfigurationPart { -+ -+ public Spawning spawning; -+ public class Spawning extends ConfigurationPart { ++ public SpawnDeadlockTimer spawnDeadlockTimer; ++ public class SpawnDeadlockTimer extends ConfigurationPart { + -+ public DeadlockTimer deadlockTimer; -+ public class DeadlockTimer extends ConfigurationPart { -+ -+ public boolean enabled = DO_OPTIMIZE; -+ public int timerTimeout = 0; -+ -+ } ++ public boolean enabled = OPTIMIZE; ++ public int timerTimeout = 0; + + } + -+ } -+ - public Player player; - public class Player extends ConfigurationPart { + } + public Structure structure; diff --git a/patches/unapplied/server/0033-Optimize-VarInts.patch b/patches/unapplied/server/0033-Optimize-VarInts.patch deleted file mode 100644 index 824004201..000000000 --- a/patches/unapplied/server/0033-Optimize-VarInts.patch +++ /dev/null @@ -1,87 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: IPECTER -Date: Thu, 4 May 2023 16:54:53 +0900 -Subject: [PATCH] Optimize VarInts - -https://github.com/PaperMC/Paper/pull/8418 - -diff --git a/src/main/java/net/minecraft/network/FriendlyByteBuf.java b/src/main/java/net/minecraft/network/FriendlyByteBuf.java -index c0bd2997fe3ebbfe926de832a36d209cc875f3e2..8bb552410207b39a3b4160a5df51410455107fcf 100644 ---- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java -+++ b/src/main/java/net/minecraft/network/FriendlyByteBuf.java -@@ -99,12 +99,26 @@ public class FriendlyByteBuf extends ByteBuf { - private static final Gson GSON = new Gson(); - - public static boolean hasItemSerializeEvent = false; // Purpur -+ public static boolean optimizeVarInts = false; // Plazma - - public FriendlyByteBuf(ByteBuf parent) { - this.source = parent; - } - -+ // Plazma start - Optimize VarInts -+ private static final int[] VARINT_EXACT_BYTE_LENGTHS = new int[33]; -+ static { -+ for (int i = 0; i <= 32; ++i) { -+ VARINT_EXACT_BYTE_LENGTHS[i] = (int) Math.ceil((31d - (i - 1)) / 7d); -+ } -+ VARINT_EXACT_BYTE_LENGTHS[32] = 1; // Special case for the number 0. -+ } -+ // Plazma end - public static int getVarIntSize(int value) { -+ // Plazma start - Optimize VarInts -+ if (optimizeVarInts) -+ return VARINT_EXACT_BYTE_LENGTHS[Integer.numberOfLeadingZeros(value)]; -+ // Plazma end - for (int j = 1; j < 5; ++j) { - if ((value & -1 << j * 7) == 0) { - return j; -@@ -620,6 +634,25 @@ public class FriendlyByteBuf extends ByteBuf { - } - - public FriendlyByteBuf writeVarInt(int value) { -+ // Plazma start - Optimize VarInts -+ if (optimizeVarInts) { -+ // Peel the one and two byte count cases explicitly as they are the most common VarInt sizes -+ // that the proxy will write, to improve inlining. -+ if ((value & (0xFFFFFFFF << 7)) == 0) { -+ writeByte(value); -+ } else if ((value & (0xFFFFFFFF << 14)) == 0) { -+ int w = (value & 0x7F | 0x80) << 8 | (value >>> 7); -+ writeShort(w); -+ } else { -+ while ((value & -128) != 0) { -+ this.writeByte(value & 127 | 128); -+ value >>>= 7; -+ } -+ this.writeByte(value); -+ } -+ return this; -+ } -+ // Plazma end - while ((value & -128) != 0) { - this.writeByte(value & 127 | 128); - value >>>= 7; -diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -index b2c9ac1947e6c9ad0e693cfeaf6f2f4bfd521aa0..525fe30b6abba295709fca3d10f9b24679112571 100644 ---- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -@@ -38,11 +38,17 @@ public class GlobalConfiguration extends ConfigurationPart { - } - - public Misc misc; -- public class Misc extends ConfigurationPart { -+ public class Misc extends ConfigurationPart.Post { - - public boolean reduceCreateRandomInstance = DO_OPTIMIZE; - public boolean doNotTriggerLootTableRefreshForNonPlayerInteraction = DO_OPTIMIZE; - public boolean doNotSendUselessEntityPackets = DO_OPTIMIZE; -+ public boolean optimizeVarInts = DO_OPTIMIZE; -+ -+ @Override -+ public void postProcess() { -+ net.minecraft.network.FriendlyByteBuf.optimizeVarInts = optimizeVarInts; -+ } - - } -