Skip to content

fix: shrink Level scan to unlocked chunks only - #44

Merged
tastybento merged 2 commits into
developfrom
fix/level-scan-optimization
Aug 19, 2026
Merged

fix: shrink Level scan to unlocked chunks only#44
tastybento merged 2 commits into
developfrom
fix/level-scan-optimization

Conversation

@tastybento

@tastybento tastybento commented Aug 19, 2026

Copy link
Copy Markdown
Member

Summary

  • Listens for IslandPreLevelEvent and temporarily sets the island's protection range to cover only the unlocked chunk ring (ring * 16 + 8 blocks) instead of the full 240-block default
  • The Level addon's IslandLevelCalculator reads the range in the same tick to build its chunk queue; the original range is restored on the next tick
  • A player with only the center chunk now triggers a scan of 1 chunk instead of ~961, eliminating the 5-minute timeout on slower servers

Reported by an admin whose /ch level command consistently timed out. The Level addon generates every chunk in the protection range via getChunkAtAsync(world, x, z, true) — with 240-block range that's ~961 void-chunk gen/load operations per dimension, which completes in ~13s on an M2 Mac but exceeds the 5-minute timeout on production VPS hardware.

Test plan

  • 4 new tests in LevelListenerTest covering: range shrink for center-only island, range matching current ring, skip when range already small, ignore non-ChunkBlock worlds
  • Full test suite passes (731 tests, 0 failures)
  • Manual test: run /ch level on test server and verify faster completion

🤖 Generated with Claude Code

https://claude.ai/code/session_01B94CWZDoiM9VevWtXb4RxF

tastybento and others added 2 commits August 18, 2026 19:05
The Level addon scans every chunk within island.getProtectionRange().
With the default of 240 blocks, that is ~961 chunks per dimension —
most of them locked and empty in ChunkBlock. On slower servers this
causes a 5-minute timeout.

Listen for IslandPreLevelEvent and temporarily set the protection range
to cover only the current unlocked ring (ring * 16 + 8). The Level
calculator builds its chunk queue in the same tick, so the original
range is restored on the next tick with no side effects.

A player with only the center chunk now triggers 1 chunk scan instead
of 961.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B94CWZDoiM9VevWtXb4RxF
240 supports up to ring 14 (841 chunks) but the default max-chunks is
441 (ring 10), so 168 is the minimum needed. The oversized default
caused the Level addon to scan ~961 chunks instead of ~441.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B94CWZDoiM9VevWtXb4RxF
@tastybento
tastybento merged commit 5cdc5c6 into develop Aug 19, 2026
1 check passed
@tastybento
tastybento deleted the fix/level-scan-optimization branch August 19, 2026 02:08
@sonarqubecloud

Copy link
Copy Markdown

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