fix: zero new island on large protection ranges via incremental capture#435
Merged
Merged
Conversation
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>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
gen=falseso it only counts chunks that exist at zero time (typically just the schematic). Fixes the 5-minute timeout that fires whenzero-new-island-levelsis on and the protection range is large (e.g. 1000 → ~16k chunks/dim, all needing generation on a fresh world).NewChunkListenerto accumulate generator block points (sea floor, nether ceiling, etc.) intoinitialCountlazily as chunks are generated during normal play. Regular level calcs subtract the now-incrementally-growninitialCount, so generator blocks always cancel out — players only get credit for their own placements.LevelsManager.addToInitialCount(island, delta)to support the listener (also migrates any legacyinitialLevel).Repro the original bug
/isto create an island.Before: console shows
Zeroing island level …thenLevel calculation timed out after 5m … Island level was being zeroed.andinitialCountis never set.After: zero scan completes in seconds (only schematic chunks); generator chunks roll into
initialCountas 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
mvn test)/is— zero scan completes quickly; level after building reflects only placed blocksisNewChunkevents fire for already-generated chunks)🤖 Generated with Claude Code