Archiviert
13
0

Fix inconsistent chunk sending with vanilla

Vanilla now loads the proper number of chunks for sending
to players. So, we can finally match their behavior after
all these years.
Dieser Commit ist enthalten in:
Spottedleaf 2023-06-08 17:43:05 -07:00
Ursprung e325e37268
Commit 8ce5219e07
15 geänderte Dateien mit 22 neuen und 22 gelöschten Zeilen

Datei anzeigen

@ -2310,7 +2310,7 @@ index 95eac2e12a16938d81ab512b00e90c5234b42834..8f7bf1f0400aeab8b7801d113d244d07
private ChunkSystem() {
diff --git a/src/main/java/io/papermc/paper/chunk/system/RegionizedPlayerChunkLoader.java b/src/main/java/io/papermc/paper/chunk/system/RegionizedPlayerChunkLoader.java
new file mode 100644
index 0000000000000000000000000000000000000000..436111365e26be6233ea36b64c1574c823f65406
index 0000000000000000000000000000000000000000..c5507553d735bbb82cbbce0308138c5a82ccc3f9
--- /dev/null
+++ b/src/main/java/io/papermc/paper/chunk/system/RegionizedPlayerChunkLoader.java
@@ -0,0 +1,1417 @@
@ -2896,14 +2896,14 @@ index 0000000000000000000000000000000000000000..436111365e26be6233ea36b64c1574c8
+
+ private static int getLoadViewDistance(final int tickViewDistance, final int playerLoadViewDistance,
+ final int worldLoadViewDistance) {
+ return Math.max(tickViewDistance, playerLoadViewDistance < 0 ? worldLoadViewDistance : playerLoadViewDistance);
+ return Math.max(tickViewDistance + 1, playerLoadViewDistance < 0 ? worldLoadViewDistance : playerLoadViewDistance);
+ }
+
+ private static int getSendViewDistance(final int loadViewDistance, final int clientViewDistance,
+ final int playerSendViewDistance, final int worldSendViewDistance) {
+ return Math.min(
+ loadViewDistance,
+ playerSendViewDistance < 0 ? (!GlobalConfiguration.get().chunkLoadingAdvanced.autoConfigSendDistance || clientViewDistance < 0 ? (worldSendViewDistance < 0 ? loadViewDistance : worldSendViewDistance) : clientViewDistance) : playerSendViewDistance
+ loadViewDistance - 1,
+ playerSendViewDistance < 0 ? (!GlobalConfiguration.get().chunkLoadingAdvanced.autoConfigSendDistance || clientViewDistance < 0 ? (worldSendViewDistance < 0 ? (loadViewDistance - 1) : worldSendViewDistance) : clientViewDistance + 1) : playerSendViewDistance
+ );
+ }
+
@ -2976,7 +2976,7 @@ index 0000000000000000000000000000000000000000..436111365e26be6233ea36b64c1574c8
+ private boolean wantChunkSent(final int chunkX, final int chunkZ) {
+ final int dx = this.lastChunkX - chunkX;
+ final int dz = this.lastChunkZ - chunkZ;
+ return Math.max(Math.abs(dx), Math.abs(dz)) <= this.lastSendDistance && wantChunkLoaded(
+ return (Math.max(Math.abs(dx), Math.abs(dz)) <= (this.lastSendDistance + 1)) && wantChunkLoaded(
+ this.lastChunkX, this.lastChunkZ, chunkX, chunkZ, this.lastSendDistance
+ );
+ }
@ -3317,7 +3317,7 @@ index 0000000000000000000000000000000000000000..436111365e26be6233ea36b64c1574c8
+ // everything <= sendDistance
+ // Note: Vanilla may want to send chunks outside the send view distance, so we do need
+ // the dist <= view check
+ final boolean sendChunk = squareDistance <= sendViewDistance
+ final boolean sendChunk = (squareDistance <= (sendViewDistance + 1))
+ && wantChunkLoaded(currentChunkX, currentChunkZ, chunkX, chunkZ, sendViewDistance);
+ final boolean sentChunk = sendChunk ? this.sentChunks.contains(chunk) : this.sentChunks.remove(chunk);
+
@ -17636,7 +17636,7 @@ index 4620e64d8eb81520b75fbfbc64603e5887c7b016..c5389e7f3665c06e487dfde3200b7e22
// Paper end
}
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 19bd6f9aee3ccb1af1b010ee51a54aa2d0bf9c84..a502d293cedb2f507e6cf1792429b36685ed1910 100644
index 19bd6f9aee3ccb1af1b010ee51a54aa2d0bf9c84..6f30a16595e352e32375530a0482d8c0ee9c1113 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -127,10 +127,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@ -18461,7 +18461,7 @@ index 19bd6f9aee3ccb1af1b010ee51a54aa2d0bf9c84..a502d293cedb2f507e6cf1792429b366
- this.updateChunkTracking(entityplayer, chunkcoordintpair, mutableobject, flag, flag1);
- });
- }
+ this.level.playerChunkLoader.setLoadDistance(this.viewDistance); // Paper - replace player loader system
+ this.level.playerChunkLoader.setLoadDistance(this.viewDistance + 1); // Paper - replace player loader system
}
}

Datei anzeigen

@ -9,7 +9,7 @@ from triggering monster spawns on a server.
Also a highly more effecient way to blanket block spawns in a world
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index a502d293cedb2f507e6cf1792429b36685ed1910..e50af28f806593a0171ad7cee5805f74b25fec89 100644
index 6f30a16595e352e32375530a0482d8c0ee9c1113..8dc2a217d018e0a11fb852cf46d4e9b5290ea6a0 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -708,7 +708,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider

Datei anzeigen

@ -8,7 +8,7 @@ Add -Ddebug.entities=true to your JVM flags to gain more information
1.17: Needs to be reworked for new entity storage system
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index e50af28f806593a0171ad7cee5805f74b25fec89..7495bd988a48cbb977ebac25854547aeb0c204e3 100644
index 8dc2a217d018e0a11fb852cf46d4e9b5290ea6a0..af92411006c3d281815b3f4c3de5f0280d3a5901 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -897,6 +897,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider

Datei anzeigen

@ -8,7 +8,7 @@ This patch also adds a chunk status cache on region files (note that
its only purpose is to cache the status on DISK)
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 7495bd988a48cbb977ebac25854547aeb0c204e3..8d22f785c32eea3a8ea2b33ddc0ccf29abf4a3b4 100644
index af92411006c3d281815b3f4c3de5f0280d3a5901..50a201c08f143117a050305b0dde6873a04efb8b 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -687,9 +687,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider

Datei anzeigen

@ -56,7 +56,7 @@ index 8f7bf1f0400aeab8b7801d113d244d0716c5eb84..fccb8d7a99bef076838ebefa233f2f00
public static void onChunkHolderCreate(final ServerLevel level, final ChunkHolder holder) {
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 8d22f785c32eea3a8ea2b33ddc0ccf29abf4a3b4..670d16f877ed7927d0cd64639d00c2e81b846908 100644
index 50a201c08f143117a050305b0dde6873a04efb8b..562e45954cc72a253f20e9a9fddf0f179baf3e7b 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -535,6 +535,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider

Datei anzeigen

@ -8,7 +8,7 @@ Sets tracking range of watermobs to animals instead of misc and simplifies code
Also ignores Enderdragon, defaulting it to Mojang's setting
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 670d16f877ed7927d0cd64639d00c2e81b846908..8c4d2b2f206d7662c0aceb30f49fa58f9426ec5c 100644
index 562e45954cc72a253f20e9a9fddf0f179baf3e7b..c00a625af27cdd80e2e4773ad93ff919f12acf31 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1326,6 +1326,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider

Datei anzeigen

@ -252,7 +252,7 @@ index 0000000000000000000000000000000000000000..11de56afaf059b00fa5bec293516bcdc
+ }
+}
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 8c4d2b2f206d7662c0aceb30f49fa58f9426ec5c..1711170ef98831dacfbf30ac22e19f47b3c4c413 100644
index c00a625af27cdd80e2e4773ad93ff919f12acf31..5cc0a39622a265e42e6b7d20e81144d1acce59b7 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -151,6 +151,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider

Datei anzeigen

@ -7,7 +7,7 @@ Suspected case would be around the technique used in .stopRiding
Stack will identify any causer of this and warn instead of crashing.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 1711170ef98831dacfbf30ac22e19f47b3c4c413..67317919d86ca4e0aa11d9f0625851fd3c1ccc84 100644
index 5cc0a39622a265e42e6b7d20e81144d1acce59b7..f1a6827a8a23795f810279597b8eefb948d4fcff 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1031,6 +1031,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider

Datei anzeigen

@ -31,7 +31,7 @@ delays anymore.
public net.minecraft.server.level.ChunkMap addEntity(Lnet/minecraft/world/entity/Entity;)V
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 67317919d86ca4e0aa11d9f0625851fd3c1ccc84..487ea2ecb0ea82e001731fa0458aff1ac9d3c0dc 100644
index f1a6827a8a23795f810279597b8eefb948d4fcff..6ad8b10e47e33221513f57c424431793177fc140 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1037,6 +1037,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider

Datei anzeigen

@ -18,7 +18,7 @@ index 05ac41e136da43284fb24a6b698ebd36318278fb..5ca3ad7b3d7606accd0a58b3c708fadb
@VisibleForTesting
static long encode(double value) {
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 487ea2ecb0ea82e001731fa0458aff1ac9d3c0dc..8d8bb430e44d7608a8aa44c7feb41797b8bbfb06 100644
index 6ad8b10e47e33221513f57c424431793177fc140..f3bbafb3475ea080826c5c795c37bc21db5622c7 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1343,9 +1343,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider

Datei anzeigen

@ -6,7 +6,7 @@ Subject: [PATCH] Use distance map to optimise entity tracker
Use the distance map to find candidate players for tracking.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 8d8bb430e44d7608a8aa44c7feb41797b8bbfb06..8c8f4829c32d469d983b8d07a33670455cd5713d 100644
index f3bbafb3475ea080826c5c795c37bc21db5622c7..897205c326f9c8d37e0320c59e09dcc40fa38711 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -157,6 +157,23 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider

Datei anzeigen

@ -42,7 +42,7 @@ index c5389e7f3665c06e487dfde3200b7e229694fbd2..4164204ba80f68a768de0ed1721c6447
private final com.destroystokyo.paper.util.maplist.ReferenceList<ServerPlayer> playersSentChunkTo = new com.destroystokyo.paper.util.maplist.ReferenceList<>();
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 8c8f4829c32d469d983b8d07a33670455cd5713d..f3dc5f6d92ce365e302eeffa511438fc234eeca2 100644
index 897205c326f9c8d37e0320c59e09dcc40fa38711..13df88938d9fe7471806d6a7ba7c00143d89b411 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -174,12 +174,24 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider

Datei anzeigen

@ -72,7 +72,7 @@ index 4164204ba80f68a768de0ed1721c6447b972a631..4ae1ba645d9fdc1eb6d5a3e4f8ceed9b
List list;
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index f3dc5f6d92ce365e302eeffa511438fc234eeca2..3184980e7de4fd41c4bfb8a808ab419354f15a32 100644
index 13df88938d9fe7471806d6a7ba7c00143d89b411..d9ef2a44e2e9f1ce32589638fad3d305dadb4cce 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -115,6 +115,8 @@ import org.bukkit.craftbukkit.generator.CustomChunkGenerator;

Datei anzeigen

@ -7,7 +7,7 @@ Reference2BooleanOpenHashMap is going to have
better lookups than HashMap.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 3184980e7de4fd41c4bfb8a808ab419354f15a32..42b383e7f23747716c89eb2de8c042ff5c35de47 100644
index d9ef2a44e2e9f1ce32589638fad3d305dadb4cce..6b8a318d9793b290798d44acdcd0d93687c8747d 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1400,7 +1400,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider

Datei anzeigen

@ -39,7 +39,7 @@ index 4ae1ba645d9fdc1eb6d5a3e4f8ceed9b4841e003..e2202389a2c4133a183cca59c4e909fc
// Paper end
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 42b383e7f23747716c89eb2de8c042ff5c35de47..9738a74103473af0b3351a654d8e58c3e73e7194 100644
index 6b8a318d9793b290798d44acdcd0d93687c8747d..f0347600b2f07105ce4802273b0cfe8631ee8876 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -157,6 +157,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider