Let bees exit hives even when the island is at its bee limit - #295
Merged
Conversation
New Release
Release 1.29.1
An admin report: at 12/12 bees, bees stored in hives could never come out — every release attempt was cancelled by the limit check, the server kept the bee as a hive occupant and retried every few ticks, spamming "Bee spawning limited to 12!" at nearby players and permanently trapping the bees. A bee leaving its hive is not a new bee: its count was decremented when it entered (EntityRemoveEvent ENTER_BLOCK) and the MONITOR tracker re-increments on exit, so the enter/exit cycle is net-zero. Exempt SpawnReason.BEEHIVE from the limit check while keeping the exit counted. If a placed hive item carries stored (never-counted) bees, the island can end slightly over its limit, which simply blocks further spawns and breeding until the population drops. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015uo8XWUxGr6VEn4TRRQ6YB
|
Merged
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
Reported by a server admin: at 12/12 bees with bees stored in hives, the stored bees could never come out. Every release attempt was cancelled by the limit check, the server kept the bee as a hive occupant and retried every few ticks, spamming "Bee spawning limited to 12!" at nearby players and permanently trapping the bees.
Analysis
The hive enter/exit cycle is net-zero in the counting model:
EntityRemoveEventwith causeENTER_BLOCK→ count decrementedCreatureSpawnEventwith reasonBEEHIVE→ MONITOR tracker re-incrementsBut the release also went through the LOW-priority limit check, so if the island was at its limit for any other reason (e.g. bees that wandered into unloaded chunks are still alive and legitimately counted), the exit was cancelled — breaking the symmetry and stranding the stored bees forever.
Fix
Exempt
SpawnReason.BEEHIVEfrom the limit check inonCreatureSpawn, alongside the existingSHOULDER_ENTITYand non-villagerBREEDINGexemptions. The exit is still counted at MONITOR priority so the tally stays accurate.Trade-off: placing a hive item carrying stored (never-counted) bees can put an island slightly over its limit, but that state is self-correcting — it blocks all further spawns and breeding until the population drops.
Tests
Three new cases in
EntityLimitListenerTest:Full suite: 308 tests, all passing.
🤖 Generated with Claude Code
https://claude.ai/code/session_015uo8XWUxGr6VEn4TRRQ6YB