Skip to content

fix: zero new island on large protection ranges via incremental capture#435

Merged
tastybento merged 2 commits into
developfrom
fix/zero-island-large-protection-range
May 16, 2026
Merged

fix: zero new island on large protection ranges via incremental capture#435
tastybento merged 2 commits into
developfrom
fix/zero-island-large-protection-range

Conversation

@tastybento
Copy link
Copy Markdown
Member

Summary

  • Switch the zero-island scan to gen=false so it only counts chunks that exist at zero time (typically just the schematic). Fixes the 5-minute timeout that fires when zero-new-island-levels is on and the protection range is large (e.g. 1000 → ~16k chunks/dim, all needing generation on a fresh world).
  • Add NewChunkListener to accumulate generator block points (sea floor, nether ceiling, etc.) into initialCount lazily as chunks are generated during normal play. Regular level calcs subtract the now-incrementally-grown initialCount, so generator blocks always cancel out — players only get credit for their own placements.
  • Add LevelsManager.addToInitialCount(island, delta) to support the listener (also migrates any legacy initialLevel).

Repro the original bug

  1. Fresh world / server / DB.
  2. Set island range and protection range to 1000.
  3. /is to create an island.

Before: console shows Zeroing island level … then Level calculation timed out after 5m … Island level was being zeroed. and initialCount is never set.
After: zero scan completes in seconds (only schematic chunks); generator chunks roll into initialCount as the player explores.

Trade-off

Per-block-type limits apply within a single scan but not across the listener's incremental additions. For aggressively-limited block types (e.g. cobblestone capped at 10k) generated heavily by terrain, the math can drift slightly. If that becomes an issue, the fix is to store per-block-type initial counts and apply limits at calc time — happy to follow up.

Test plan

  • Build/tests pass locally (mvn test)
  • BSkyBlock: fresh world, range 1000, /is — zero scan completes quickly; level after building reflects only placed blocks
  • AcidIsland-style game mode with sea floor: explore beyond schematic — newly generated sea floor does not inflate level
  • Legacy island (already zeroed pre-upgrade): no double-counting on chunk loads (no isNewChunk events fire for already-generated chunks)

🤖 Generated with Claude Code

tastybento and others added 2 commits May 15, 2026 07:00
The zero-island scan force-generated every chunk in the protection range
with gen=true. On islands with a large range (e.g. 1000 → ~16k chunks
per dimension on a fresh world) this blew past the 5-minute calculation
timeout, leaving initialCount unset.

Switch the zero scan to gen=false so it only counts chunks that exist
at zero time (typically just the schematic), and add NewChunkListener
to accumulate generator block points (sea floor, nether ceiling, etc.)
into initialCount lazily as chunks are generated during normal play.
Regular level calcs subtract the now-incrementally-grown initialCount,
so generator blocks always cancel out and players only get credit for
their own placements.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- S2184: keep the chunk-centre Location arithmetic in double space by
  using +8.0 so SonarQube does not flag a theoretical int-overflow
  before implicit widening.
- S107: replace the 12-parameter scan helper with a ScanContext record
  bundling all main-thread snapshot state.
- S3776 / S135: split the nested scan into scanRow / scanColumn /
  valueAt helpers so each method is small, has at most one return /
  continue, and total cognitive complexity drops below 15.

No behaviour change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

@tastybento tastybento merged commit bec4ec1 into develop May 16, 2026
3 checks passed
@tastybento tastybento deleted the fix/zero-island-large-protection-range branch May 16, 2026 00:47
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