From a50d7c340b9922eab16fd9f246269b4c75453648 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Fri, 22 Sep 2023 17:07:02 -0700 Subject: [PATCH] Make sure to maintain the players sent to set for ChunkHolder Required for proper block/light updates to clients --- patches/server/0018-Rewrite-chunk-system.patch | 10 ++++++---- .../server/0500-Player-Chunk-Load-Unload-Events.patch | 10 +++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/patches/server/0018-Rewrite-chunk-system.patch b/patches/server/0018-Rewrite-chunk-system.patch index 41e3818a58b4..50757905e192 100644 --- a/patches/server/0018-Rewrite-chunk-system.patch +++ b/patches/server/0018-Rewrite-chunk-system.patch @@ -20616,15 +20616,16 @@ index e96a0ca47e4701ba187555bd92c968345bc85677..73b96f804079288e9c5fcc11da54e61e + // Paper end } diff --git a/src/main/java/net/minecraft/server/network/PlayerChunkSender.java b/src/main/java/net/minecraft/server/network/PlayerChunkSender.java -index c509a1318bcef38fd4927e38b6ee9846853e2d15..0f7ee2eea68a5c910bdf4d6263ed09cbed592516 100644 +index c509a1318bcef38fd4927e38b6ee9846853e2d15..5de5209e04d631bd6a50e28e8d3abebf148252c1 100644 --- a/src/main/java/net/minecraft/server/network/PlayerChunkSender.java +++ b/src/main/java/net/minecraft/server/network/PlayerChunkSender.java -@@ -42,14 +42,21 @@ public class PlayerChunkSender { +@@ -42,14 +42,22 @@ public class PlayerChunkSender { this.pendingChunks.add(chunk.getPos().toLong()); } + // Paper start - rewrite player chunk loader + public static void dropChunkStatic(ServerPlayer player, ChunkPos pos) { ++ player.serverLevel().chunkSource.chunkMap.getVisibleChunkIfPresent(pos.toLong()).removePlayer(player); + player.connection.send(new ClientboundForgetLevelChunkPacket(pos)); + } + // Paper end - rewrite player chunk loader @@ -20642,16 +20643,17 @@ index c509a1318bcef38fd4927e38b6ee9846853e2d15..0f7ee2eea68a5c910bdf4d6263ed09cb if (this.unacknowledgedBatches < this.maxUnacknowledgedBatches) { float f = Math.max(1.0F, this.desiredChunksPerTick); this.batchQuota = Math.min(this.batchQuota + this.desiredChunksPerTick, f); -@@ -75,7 +82,7 @@ public class PlayerChunkSender { +@@ -75,7 +83,8 @@ public class PlayerChunkSender { } } - private static void sendChunk(ServerGamePacketListenerImpl handler, ServerLevel world, LevelChunk chunk) { + public static void sendChunk(ServerGamePacketListenerImpl handler, ServerLevel world, LevelChunk chunk) { // Paper - rewrite chunk loader - public ++ handler.player.serverLevel().chunkSource.chunkMap.getVisibleChunkIfPresent(chunk.getPos().toLong()).addPlayer(handler.player); handler.send(new ClientboundLevelChunkWithLightPacket(chunk, world.getLightEngine(), (BitSet)null, (BitSet)null)); ChunkPos chunkPos = chunk.getPos(); DebugPackets.sendPoiPacketsForChunk(world, chunkPos); -@@ -100,6 +107,7 @@ public class PlayerChunkSender { +@@ -100,6 +109,7 @@ public class PlayerChunkSender { } public void onChunkBatchReceivedByClient(float desiredBatchSize) { diff --git a/patches/server/0500-Player-Chunk-Load-Unload-Events.patch b/patches/server/0500-Player-Chunk-Load-Unload-Events.patch index 4d939dbfcd28..3afc56b4091b 100644 --- a/patches/server/0500-Player-Chunk-Load-Unload-Events.patch +++ b/patches/server/0500-Player-Chunk-Load-Unload-Events.patch @@ -5,12 +5,12 @@ Subject: [PATCH] Player Chunk Load/Unload Events diff --git a/src/main/java/net/minecraft/server/network/PlayerChunkSender.java b/src/main/java/net/minecraft/server/network/PlayerChunkSender.java -index 0f7ee2eea68a5c910bdf4d6263ed09cbed592516..ef85236b958d8187959c7d446bc2f3c7480854bb 100644 +index 5de5209e04d631bd6a50e28e8d3abebf148252c1..f8924bc2f82e7563419ce98153f9fb87d4ed2547 100644 --- a/src/main/java/net/minecraft/server/network/PlayerChunkSender.java +++ b/src/main/java/net/minecraft/server/network/PlayerChunkSender.java -@@ -45,6 +45,11 @@ public class PlayerChunkSender { - // Paper start - rewrite player chunk loader +@@ -46,6 +46,11 @@ public class PlayerChunkSender { public static void dropChunkStatic(ServerPlayer player, ChunkPos pos) { + player.serverLevel().chunkSource.chunkMap.getVisibleChunkIfPresent(pos.toLong()).removePlayer(player); player.connection.send(new ClientboundForgetLevelChunkPacket(pos)); + // Paper start + if (io.papermc.paper.event.packet.PlayerChunkUnloadEvent.getHandlerList().getRegisteredListeners().length > 0) { @@ -20,9 +20,9 @@ index 0f7ee2eea68a5c910bdf4d6263ed09cbed592516..ef85236b958d8187959c7d446bc2f3c7 } // Paper end - rewrite player chunk loader -@@ -84,6 +89,11 @@ public class PlayerChunkSender { - +@@ -86,6 +91,11 @@ public class PlayerChunkSender { public static void sendChunk(ServerGamePacketListenerImpl handler, ServerLevel world, LevelChunk chunk) { // Paper - rewrite chunk loader - public + handler.player.serverLevel().chunkSource.chunkMap.getVisibleChunkIfPresent(chunk.getPos().toLong()).addPlayer(handler.player); handler.send(new ClientboundLevelChunkWithLightPacket(chunk, world.getLightEngine(), (BitSet)null, (BitSet)null)); + // Paper start + if (io.papermc.paper.event.packet.PlayerChunkLoadEvent.getHandlerList().getRegisteredListeners().length > 0) {