Skip to content

Commit

Permalink
Make currently loading chunk available during entity loading
Browse files Browse the repository at this point in the history
Fixes deadlock when mods attempt to retrieve the current chunk while loading entities (from screenEntity or otherwise)
  • Loading branch information
jpenilla committed Aug 22, 2024
1 parent 5788bb6 commit 8418cd3
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8418cd3

Please sign in to comment.