Skip to content

Resolves issue causing edge case crash#96

Open
JoeStaff wants to merge 3 commits intoxt9:1.12from
JoeStaff:patch-1
Open

Resolves issue causing edge case crash#96
JoeStaff wants to merge 3 commits intoxt9:1.12from
JoeStaff:patch-1

Conversation

@JoeStaff
Copy link

@JoeStaff JoeStaff commented Mar 20, 2026

Fixes a crash caused by unsafe modification of killedEntityUUIDBlacklist in EntityDeathHandler, which could result in a NoSuchElementException during mob death events.

Root Cause

  • isEntityBlacklisted() iterates over killedEntityUUIDBlacklist using a stream (creating an iterator).
  • At the same time, cullEntityBlacklist() calls clear() on the same list.
  • When multiple LivingDeathEvents fire in quick succession (e.g., automated mob killing), this leads to modification of the list while it is being iterated.
  • This violates iterator safety and causes a crash: java.util.NoSuchElementException at java.util.AbstractList$Itr.next

Changes

Replaced stream-based lookup in isEntityBlacklisted() with a direct .contains() check:

  • Avoids unnecessary iteration and allocation
  • Improves performance and readability

Updated cullEntityBlacklist() to avoid unsafe in-place mutation:

  • Replaces the list instead of clearing it while it may be in use

Issue is reproducible with rapidly killing mobs through automated means.

Test: ran high rate mob grinder (using mob-grinding-utils, roost, extra utilities) resulting in a mob kill every 1-3 ticks. Before fix, the game would crash every 1-3 hours. After fix, I've gone now well over 12 hours with no crash.

@JoeStaff JoeStaff changed the title (WIP) Resolves issue causing edge case crash Resolves issue causing edge case crash Mar 20, 2026
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.

1 participant