From 3f80f358d109e36f5d958df9f1a67c92151a400d Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Thu, 22 Aug 2024 10:12:46 -0700 Subject: [PATCH] Make currently loading chunk available during entity loading (#4) Fixes deadlock when mods attempt to retrieve the current chunk while loading entities (from screenEntity or otherwise) --- .../chunk_system/scheduling/task/ChunkFullTask.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/task/ChunkFullTask.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/task/ChunkFullTask.java index c1135867..a2f235de 100644 --- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/task/ChunkFullTask.java +++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/task/ChunkFullTask.java @@ -78,13 +78,13 @@ public void run() { try { platformHooks.setCurrentlyLoading(this.chunkHolder.vanillaChunkHolder, chunk); chunk.runPostLoad(); + // Unlike Vanilla, we load the entity chunk here, as we load the NBT in empty status (unlike Vanilla) + // This brings entity addition back in line with older versions of the game + // Since we load the NBT in the empty status, this will never block for I/O + ((ChunkSystemServerLevel)this.world).moonrise$getChunkTaskScheduler().chunkHolderManager.getOrCreateEntityChunk(this.chunkX, this.chunkZ, false); } finally { platformHooks.setCurrentlyLoading(this.chunkHolder.vanillaChunkHolder, null); } - // Unlike Vanilla, we load the entity chunk here, as we load the NBT in empty status (unlike Vanilla) - // This brings entity addition back in line with older versions of the game - // Since we load the NBT in the empty status, this will never block for I/O - ((ChunkSystemServerLevel)this.world).moonrise$getChunkTaskScheduler().chunkHolderManager.getOrCreateEntityChunk(this.chunkX, this.chunkZ, false); // we don't need the entitiesInLevel, not sure why it's there chunk.setLoaded(true);