Compare commits

..

3 Commits

Author SHA1 Message Date
IPECTER
8058507e4d Fix 2023-09-07 15:47:39 +09:00
IPECTER
ef2cf1d921 Fix Incompat with CoreProtect 2023-09-07 02:20:23 +09:00
IPECTER
e1445c2d7d Fix Optimize VarInts
Thank you, Martijn!
2023-09-07 00:54:18 +09:00
5 changed files with 36 additions and 18 deletions

View File

@@ -7,10 +7,10 @@ Original: someaddons/chunksending
Copyright (C) 2023 someaddons
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
index e2202389a2c4133a183cca59c4e909fc419379ab..ccb7ff8832d3673a46d0a285f09d57d12bc0203a 100644
index e2202389a2c4133a183cca59c4e909fc419379ab..b3e731c122b315d28ae51d32b798f818e270c7ff 100644
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
@@ -398,9 +398,11 @@ public class ChunkHolder {
@@ -398,9 +398,12 @@ public class ChunkHolder {
// Paper end - rewrite chunk system
private void broadcast(List<ServerPlayer> players, Packet<?> packet) {
@@ -18,9 +18,10 @@ index e2202389a2c4133a183cca59c4e909fc419379ab..ccb7ff8832d3673a46d0a285f09d57d1
- entityplayer.connection.send(packet);
- });
+ // Plazma start
+ for (ServerPlayer player : players)
+ if (this.chunkMap.level.plazmaLevelConfiguration().chunkSending.enabled && !player.attachToPending(pos, packet))
+ player.connection.send(packet);
+ for (ServerPlayer player : players) {
+ if (this.chunkMap.level.plazmaLevelConfiguration().chunkSending.enabled && player.attachToPending(pos, packet)) continue;
+ player.connection.send(packet);
+ }
+ // Plazma end
}

View File

@@ -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;
+ }
}

View File

@@ -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;
}

View File

@@ -162,10 +162,10 @@ index 5695c5116c8a338b2e41aafcb2dc9f2146856970..b2291854b9803fe01d40e8a1d76d6ff3
public Holder<Biome> 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;

View File

@@ -69,10 +69,10 @@ index 9ffb6999171f602f0b113dac40e0130410cad870..49b5fece692cd5da99ed21d7fd0864ce
public <C extends Container, T extends Recipe<C>> List<T> getRecipesFor(RecipeType<T> 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;