Skip to content

Let bees exit hives even when the island is at its bee limit - #295

Merged
tastybento merged 3 commits into
developfrom
fix/bee-hive-exit-at-limit
Aug 14, 2026
Merged

Let bees exit hives even when the island is at its bee limit#295
tastybento merged 3 commits into
developfrom
fix/bee-hive-exit-at-limit

Conversation

@tastybento

Copy link
Copy Markdown
Member

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:

  • Bee enters hive → EntityRemoveEvent with cause ENTER_BLOCK → count decremented
  • Hive releases bee → CreatureSpawnEvent with reason BEEHIVE → MONITOR tracker re-increments

But 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.BEEHIVE from the limit check in onCreatureSpawn, alongside the existing SHOULDER_ENTITY and non-villager BREEDING exemptions. 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:

  • Exit at the limit is not cancelled and skips the island lookup entirely
  • Exit still increments the count and maps the bee to its island
  • Full enter/exit round-trip ends net-zero

Full suite: 308 tests, all passing.

🤖 Generated with Claude Code

https://claude.ai/code/session_015uo8XWUxGr6VEn4TRRQ6YB

tastybento and others added 3 commits July 10, 2026 16:28
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
@sonarqubecloud

Copy link
Copy Markdown

@tastybento
tastybento merged commit d727976 into develop Aug 14, 2026
3 checks passed
@tastybento
tastybento deleted the fix/bee-hive-exit-at-limit branch August 14, 2026 15:24
@tastybento tastybento mentioned this pull request Aug 14, 2026
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