From ed3350e66e6a4f41276728e98c3dffaada071b71 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Thu, 11 Jul 2024 07:16:42 -0700 Subject: [PATCH] Fix recursive chunk loading in chunk unload event Since the chunk may not even be at a loaded ticket level, the getChunk call may invoke a sync load. To prevent this, we can retrieve the full loaded chunk first which is guaranteed to be non-null when unloading. --- .../Chunk-System-Starlight-from-Moonrise.patch | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/patches/server/Chunk-System-Starlight-from-Moonrise.patch b/patches/server/Chunk-System-Starlight-from-Moonrise.patch index afdb656158..6f6619ebf3 100644 --- a/patches/server/Chunk-System-Starlight-from-Moonrise.patch +++ b/patches/server/Chunk-System-Starlight-from-Moonrise.patch @@ -29481,6 +29481,19 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/jav index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +@@ -0,0 +0,0 @@ public class CraftChunk implements Chunk { + } + + public ChunkAccess getHandle(ChunkStatus chunkStatus) { ++ // Paper start - rewrite chunk system ++ net.minecraft.world.level.chunk.LevelChunk full = this.worldServer.getChunkIfLoaded(this.x, this.z); ++ if (full != null) { ++ return full; ++ } ++ // Paper end - rewrite chunk system + ChunkAccess chunkAccess = this.worldServer.getChunk(this.x, this.z, chunkStatus); + + // SPIGOT-7332: Get unwrapped extension @@ -0,0 +0,0 @@ public class CraftChunk implements Chunk { @Override