diff --git a/patches/server/0034-Optimize-VarInts.patch b/patches/server/0034-Optimize-VarInts.patch index fb8db1a66..824004201 100644 --- a/patches/server/0034-Optimize-VarInts.patch +++ b/patches/server/0034-Optimize-VarInts.patch @@ -6,10 +6,16 @@ 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..6108f3aa438b96e817c3a2e582c2c817f096e2eb 100644 +index c0bd2997fe3ebbfe926de832a36d209cc875f3e2..8bb552410207b39a3b4160a5df51410455107fcf 100644 --- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java +++ b/src/main/java/net/minecraft/network/FriendlyByteBuf.java -@@ -104,7 +104,20 @@ public class FriendlyByteBuf extends ByteBuf { +@@ -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; } @@ -24,18 +30,18 @@ index c0bd2997fe3ebbfe926de832a36d209cc875f3e2..6108f3aa438b96e817c3a2e582c2c817 + // Plazma end public static int getVarIntSize(int value) { + // Plazma start - Optimize VarInts -+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.optimizeVarInts) ++ 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 +633,25 @@ public class FriendlyByteBuf extends ByteBuf { +@@ -620,6 +634,25 @@ public class FriendlyByteBuf extends ByteBuf { } public FriendlyByteBuf writeVarInt(int value) { + // Plazma start - Optimize VarInts -+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.optimizeVarInts) { ++ 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) { @@ -57,14 +63,25 @@ index c0bd2997fe3ebbfe926de832a36d209cc875f3e2..6108f3aa438b96e817c3a2e582c2c817 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..c1ff5d20dd3b74062837fd30a7b3966e16bdf54c 100644 +index b2c9ac1947e6c9ad0e693cfeaf6f2f4bfd521aa0..525fe30b6abba295709fca3d10f9b24679112571 100644 --- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java +++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -@@ -43,6 +43,7 @@ public class GlobalConfiguration extends ConfigurationPart { +@@ -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; ++ } } diff --git a/patches/server/0042-CarpetFixes-Configuration.patch b/patches/server/0042-CarpetFixes-Configuration.patch index 6de89276f..bec61e876 100644 --- a/patches/server/0042-CarpetFixes-Configuration.patch +++ b/patches/server/0042-CarpetFixes-Configuration.patch @@ -5,10 +5,10 @@ Subject: [PATCH] CarpetFixes-Configuration diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -index c1ff5d20dd3b74062837fd30a7b3966e16bdf54c..0810cb07d7e5b7752fd27e6cc4bfc02c5b1497c4 100644 +index 525fe30b6abba295709fca3d10f9b24679112571..49d5292697fdc6f23874557dd2db9d1fcda750f3 100644 --- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java +++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -@@ -71,4 +71,12 @@ public class GlobalConfiguration extends ConfigurationPart { +@@ -76,4 +76,12 @@ public class GlobalConfiguration extends ConfigurationPart { public int timerTimeOut = 0; } diff --git a/patches/server/0043-CarpetFixes-Optimizations-BiomeManager.patch b/patches/server/0043-CarpetFixes-Optimizations-BiomeManager.patch index 77a992999..2847f7508 100644 --- a/patches/server/0043-CarpetFixes-Optimizations-BiomeManager.patch +++ b/patches/server/0043-CarpetFixes-Optimizations-BiomeManager.patch @@ -162,10 +162,10 @@ index 5695c5116c8a338b2e41aafcb2dc9f2146856970..b2291854b9803fe01d40e8a1d76d6ff3 public Holder getNoiseBiomeAtPosition(double x, double y, double z) { diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -index 0810cb07d7e5b7752fd27e6cc4bfc02c5b1497c4..42b0ec06d0e5ed1f947d6c14067b1dd725ec839a 100644 +index 49d5292697fdc6f23874557dd2db9d1fcda750f3..d329f77ab19ac781506c26909591fa4ae9dabb1e 100644 --- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java +++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -@@ -77,6 +77,11 @@ public class GlobalConfiguration extends ConfigurationPart { +@@ -82,6 +82,11 @@ public class GlobalConfiguration extends ConfigurationPart { public class CarpetFixes extends ConfigurationPart { public boolean enabled = DO_OPTIMIZE; diff --git a/patches/server/0044-CarpetFixes-Optimizations-RecipeManager.patch b/patches/server/0044-CarpetFixes-Optimizations-RecipeManager.patch index 710d9d0ff..e1cc77b5c 100644 --- a/patches/server/0044-CarpetFixes-Optimizations-RecipeManager.patch +++ b/patches/server/0044-CarpetFixes-Optimizations-RecipeManager.patch @@ -69,10 +69,10 @@ index 9ffb6999171f602f0b113dac40e0130410cad870..49b5fece692cd5da99ed21d7fd0864ce public > List getRecipesFor(RecipeType type, C inventory, Level world) { diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -index 42b0ec06d0e5ed1f947d6c14067b1dd725ec839a..4348486b8d5eef32132652ceaa890fff0d50ab98 100644 +index d329f77ab19ac781506c26909591fa4ae9dabb1e..36511f71fcf3a8a5da746dd087003861a4f0a8f4 100644 --- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java +++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -@@ -78,10 +78,15 @@ public class GlobalConfiguration extends ConfigurationPart { +@@ -83,10 +83,15 @@ public class GlobalConfiguration extends ConfigurationPart { public boolean enabled = DO_OPTIMIZE; boolean optimizedBiomeAccess = true;