Suppress structures in the spawn area too (#116)#118
Merged
Conversation
The structure listener was registered in onEnable(), but createWorlds() runs before onEnable() and generating a world also generates its spawn-area chunks. Those first structures were therefore placed before the listener existed, so a disabled structure could still appear near spawn. Register the listener at the start of createWorlds(), before any world is created. Because createWorlds() assigns islandWorld from the return value of createWorld(), the island-world reference is still null while the spawn chunks generate, so inWorld() would compare against a null world and throw. Match on the configured world name instead via a new isCaveOverworld() helper, used by both handlers. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015GBGsNFUshypm5Sj8KQsEa
|
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.



Problem
Follow-up to #117, closing the other half of #116: a disabled structure could still generate near spawn.
StructureGenerationListenerwas registered inonEnable(), but BentoBox callscreateWorlds()beforeonEnable(), and creating a world also generates its spawn-area chunks. Those first structures were placed before the listener existed, so they escaped suppression. This matches the reporter finding a trial chamber despitetrial_chambers: false, and the debug run where the listener registered ~5 s afterCreating CaveBlock world ....Fix
Register the listener at the start of
createWorlds(), before any world is created, so it is active for the initial spawn generation.That alone isn't sufficient:
createWorlds()assignsislandWorldfrom the return value ofcreateWorld(), soislandWorldis stillnullwhile the spawn chunks generate. The asyncAsyncStructureSpawnEventhandler callingaddon.inWorld(world)would then compare against a null world (Util.sameWorld→stripName(null)→ NPE) and silently fail to cancel.So both handlers now match on the configured world name via a new
isCaveOverworld()helper instead ofinWorld(), removing the dependency on the not-yet-assigned world reference.Testing
mvn test— all 78 pass. The listener tests were updated to match on world name (getWorldName()/World#getName()) rather thaninWorld().Note
Structures already written to region files by a previous run are unaffected — clearing them needs a world reset.
🤖 Generated with Claude Code