fix: self-healing per-chunk handicap and address Copilot review · BentoBoxWorld/Level@22f20bb · GitHub
Skip to content

Commit 22f20bb

Browse files
tastybentoclaude
andcommitted
fix: self-healing per-chunk handicap and address Copilot review
The lazy-zero handicap was a single number written once at zero scan and only updated by ChunkLoadEvent.isNewChunk=true. Chunks that materialized through any other path — Poseidon pregenerating around the island grid before the island existed, async-load misses at zero-scan time, late chunk decoration — were silently missing from the handicap and showed up as positive level on islands the player had never touched. Track handicap value per chunk on IslandLevels (keyed by worldName:chunkKey), then reconcile on every scan: chunks the live scan visits that aren't in the persisted map are folded into both the map and initialCount in one atomic write, so the next scan reads level=0 for that previously-missing terrain. Frozen-once semantics ensure player builds still grow the live total without inflating the handicap, and an empty map with a non-zero initialCount is treated as legacy migration so existing islands don't get double-credited on upgrade. Also addresses Copilot's PR #441 review: - delete unbounded queuedChunks dedup from NewChunkListener (isNewChunk() is the dedup; the defensive set grew without bound) - route per-chunk scoring through IslandLevelCalculator's real processBlock logic so custom blocks, slabs, and configured values match the regular scan - clamp completePendingZero at zero, remove the per-island map entry when it empties, and close the add/complete race via compute() Multi-dim correctness: the visited/deferred maps now key on worldName:chunkKey so the same (x,z) in different dimensions tracks separately. drainZeroScanDeferred returns the missed entries as a map which the caller reconciles into the per-chunk handicap. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0548a0a commit 22f20bb

7 files changed

Lines changed: 535 additions & 183 deletions

File tree

src/main/java/world/bentobox/level/LevelsManager.java

Lines changed: 175 additions & 36 deletions

0 commit comments

Comments
 (0)