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)
This commit is contained in:
Jason Penilla
2024-08-22 10:12:46 -07:00
committed by GitHub
parent 5788bb64aa
commit 3f80f358d1

View File

@@ -78,13 +78,13 @@ public final class ChunkFullTask extends ChunkProgressionTask implements Runnabl
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);