Skip to content

Suppress hit-limit spam from natural breeding and add breed-path tests - #291

Merged
tastybento merged 1 commit into
developfrom
fix/breed-notification-and-tests
Jul 23, 2026
Merged

Suppress hit-limit spam from natural breeding and add breed-path tests#291
tastybento merged 1 commit into
developfrom
fix/breed-notification-and-tests

Conversation

@tastybento

Copy link
Copy Markdown
Member

Follow-up to #290, addressing the review notes.

Notification suppression for natural breeding

BREEDING is not in tellPlayers' suppressed-reason list, so after #290 an automated breeder (e.g. a villager breeder at its limit) would notify every nearby player — and call updateInventory() — on every breed attempt. The limit check now threads a notify flag through checkLimit/processIsland: natural (null/non-player breeder) breeding cancels silently, while player-fed breeding still notifies so the player knows why no baby appeared and their food was kept.

Villager cooldown — verified, no code change needed

The review flagged that villagers at the limit might retry every tick because "Villager isn't Breedable". That turned out to be outdated for the targeted API: AbstractVillager extends Breedable in Paper 1.21.11, so the existing instanceof Breedable branch already applies setBreed(false) (a breeding-age cooldown, which vanilla villager breeding also respects since it requires age == 0). A regression test now locks this in.

New tests (45 → 50)

  • Natural breeding at limit → cancelled, both parents put on cooldown, no notification scheduled
  • Natural breeding under limit → not cancelled, parents untouched
  • Non-op player breeding at limit → cancelled with notification to nearby players
  • Villager natural breeding at limit → cancelled, setBreed(false) applied via the Breedable branch
  • EntityAddToWorldEvent for a Player → not added to entityIslandMap, no island lookup (guards the leak fix from Fix entity overcount from natural breeding and recount gaps #290)

Also extracted mockChicken()/mockVillager() test helpers (the op-bypass test built the same three mocks inline).

Not covered: a RecountCalculator test for the boat fix — scanEntities is private inside the chunk-scanning pipeline and has no existing test scaffolding; building that is out of proportion for a one-line instanceof change.

Full suite: 305 tests, all green.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UyA5AKzK44TXSxXQbR6DNc

Follow-up to #290:

- A natural breed attempt (null/non-player breeder) at the limit no
  longer notifies nearby players — an auto-breeder at its limit would
  otherwise message everyone within range on every attempt. Player-fed
  breeding still notifies, since the player needs to know why no baby
  appeared.
- Verified villagers are covered by the setBreed(false) cooldown branch:
  AbstractVillager extends Breedable in the targeted Paper API, so no
  code change was needed — a regression test now locks this in.
- New tests: natural breeding at/under limit, non-op player breeding at
  limit (with notification), villager breed cooldown, and Player
  exclusion from the entity-island map on EntityAddToWorldEvent.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UyA5AKzK44TXSxXQbR6DNc
@sonarqubecloud

Copy link
Copy Markdown

@tastybento
tastybento merged commit 24e6a1d into develop Jul 23, 2026
3 checks passed
@tastybento
tastybento deleted the fix/breed-notification-and-tests branch July 23, 2026 15:31
@tastybento tastybento mentioned this pull request Jul 23, 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