Skip to content

Fix CME in EntityVengeanceSpirit.canSpawnNew during dimension unload#1182

Merged
rubensworks merged 2 commits intomaster-1.21-ltsfrom
copilot/fix-concurrent-modification-exception-again
Apr 8, 2026
Merged

Fix CME in EntityVengeanceSpirit.canSpawnNew during dimension unload#1182
rubensworks merged 2 commits intomaster-1.21-ltsfrom
copilot/fix-concurrent-modification-exception-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

When a mob dies during dimension teardown, vengeanceEvent fires and canSpawnNew calls WorldHelpers.foldArea → level.getBlockState(). On ServerLevel, this triggers ServerChunkCache.runDistanceManagerUpdates on a DistanceManager whose ticket map is being concurrently modified, causing a ConcurrentModificationException.

Change

Added level1.isLoaded(blockPos1) guard in the canSpawnNew block-scan lambda. Level.isLoaded() delegates to getChunkSource().hasChunk(), which checks loaded state without forcing a chunk load. Unloaded positions skip the spirit-blocker tag check (no blocker assumed).

// Before
(input, level1, blockPos1) -> input
    && !level1.getBlockState(blockPos1).is(TAG_SPIRIT_BLOCKER)

// After
(input, level1, blockPos1) -> input
    && (!level1.isLoaded(blockPos1) || !level1.getBlockState(blockPos1).is(TAG_SPIRIT_BLOCKER))

@coveralls
Copy link
Copy Markdown

coveralls commented Apr 8, 2026

Coverage Report for CI Build 24149285071

Coverage decreased (-0.002%) to 28.5%

Details

  • Coverage decreased (-0.002%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 15069
Covered Lines: 5018
Line Coverage: 33.3%
Relevant Branches: 5612
Covered Branches: 876
Branch Coverage: 15.61%
Branches in Coverage %: Yes
Coverage Strength: 1.55 hits per line

💛 - Coveralls

…New during dimension unload

Agent-Logs-Url: https://github.com/CyclopsMC/EvilCraft/sessions/70f33748-f5e4-44bb-b0ba-4b476bbb08b1

Co-authored-by: rubensworks <440384+rubensworks@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix ConcurrentModificationException in EntityVengeanceSpirit.canSpawnNew Fix CME in EntityVengeanceSpirit.canSpawnNew during dimension unload Apr 8, 2026
Copilot AI requested a review from rubensworks April 8, 2026 17:31
@rubensworks rubensworks marked this pull request as ready for review April 8, 2026 17:33
@rubensworks rubensworks merged commit a549484 into master-1.21-lts Apr 8, 2026
3 checks passed
@rubensworks rubensworks deleted the copilot/fix-concurrent-modification-exception-again branch April 8, 2026 17:33
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.

ConcurrentModificationException in EntityVengeanceSpirit.canSpawnNew when mob dies during dimension unload

3 participants