Skip to content

fix MC-89146 NPE on reentrant block entity removal - #577

Open
0x969 wants to merge 1 commit into
isXander:mainfrom
0x969:patch/mc-89146
Open

0x969 wants to merge 1 commit into
isXander:mainfrom
0x969:patch/mc-89146

Conversation

@0x969

@0x969 0x969 commented Dec 1, 2026

Copy link
Copy Markdown

Fixes #573

The linked map from the MC-89146 fix breaks LevelChunk.clearAllBlockEntities when removal re-enters it. The loop calls setRemoved on every block entity, a jukebox fires its level event there, and mods hooked into that (Cooking for Blockheads in the issue) call getBlockEntity, which drops removed entries from the map mid-iteration. fastutil caches the next slot before the consumer runs, so the next read hits an empty slot and passes null.

This wraps the first forEach in clearAllBlockEntities (the block entity one, not the ticker one) and iterates a snapshot instead. Removal order stays the same and nothing changes when the map isn't touched mid-loop.

Validated with ./gradlew compileJava spotlessCheck. Reproducing the actual crash needs the mod stack from the issue, so no runtime test here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] MC-89146 fix: NPE in LevelChunk.clearAllBlockEntities when a block entity removal re-enters the linked map

1 participant