Skip to content

Commit

Permalink
Make sure to maintain the players sent to set for ChunkHolder
Browse files Browse the repository at this point in the history
Required for proper block/light updates to clients
  • Loading branch information
Spottedleaf committed Sep 23, 2023
1 parent 0280723 commit a50d7c3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
10 changes: 6 additions & 4 deletions patches/server/0018-Rewrite-chunk-system.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions patches/server/0500-Player-Chunk-Load-Unload-Events.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit a50d7c3

Please sign in to comment.