From d34fb878bbfe7a7f6057b17033462f341ceb3c3a Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Mon, 3 Apr 2023 22:48:59 -0700 Subject: [PATCH] Always send untrack chunk packets Vanilla inserted the alive check so that dead players could see the chunks around them, but in Folia we do not remove dead players so chunks will still load for them. This prevents the client from having chunks in memory it should not. --- patches/server/0005-Threaded-Regions.patch | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/patches/server/0005-Threaded-Regions.patch b/patches/server/0005-Threaded-Regions.patch index e438ef2..b3cde83 100644 --- a/patches/server/0005-Threaded-Regions.patch +++ b/patches/server/0005-Threaded-Regions.patch @@ -15976,7 +15976,7 @@ index bf1a77cf9bbea4e2104b2a8c61309e740f28d51b..acc8af33ad8534d812908b0feb9a1963 for (ServerPlayer player : ServerLevel.this.players) { player.getBukkitEntity().onEntityRemove(entity); diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 4231c3fe14a621d237bdc3d56c593f0adc0a7bc6..7935fccf078ba92b3bafde7eb3cd146f57af37c2 100644 +index 4231c3fe14a621d237bdc3d56c593f0adc0a7bc6..5f53c9ad5d64053a2e29c58ddb62e7d2bd176efe 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java @@ -188,7 +188,7 @@ import org.bukkit.inventory.MainHand; @@ -16490,6 +16490,15 @@ index 4231c3fe14a621d237bdc3d56c593f0adc0a7bc6..7935fccf078ba92b3bafde7eb3cd146f this.camera = (Entity) (entity == null ? this : entity); if (entity1 != this.camera) { // Paper start - Add PlayerStartSpectatingEntityEvent and PlayerStopSpectatingEntity Event +@@ -2291,7 +2678,7 @@ public class ServerPlayer extends Player { + } + + public void untrackChunk(ChunkPos chunkPos) { +- if (this.isAlive()) { ++ if (true || this.isAlive()) { // Folia - region threading - always untrack chunk now that the player is retained in the world after death + this.connection.send(new ClientboundForgetLevelChunkPacket(chunkPos.x, chunkPos.z)); + // Paper start + if(io.papermc.paper.event.packet.PlayerChunkUnloadEvent.getHandlerList().getRegisteredListeners().length > 0){ @@ -2570,7 +2957,7 @@ public class ServerPlayer extends Player { this.experienceLevel = this.newLevel; this.totalExperience = this.newTotalExp;