Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.21.1] Cancelled villager breeding causes beds to be wrongly occupied #1606

Open
RedstoneDubstep opened this issue Oct 20, 2024 · 0 comments
Labels
triage Needs triaging and confirmation

Comments

@RedstoneDubstep
Copy link
Contributor

Minecraft Version: 1.21.1

NeoForge Version: 21.1.68

Steps to Reproduce:

  1. Create a test mod with an event listener which listens to the FinalizeSpawnEvent, and cancels it & calls setSpawnCancelled on the event if the entity in the event is a Villager, the MobSpawnType is BREEDING and the gametime is <24000 ticks (or any other arbitrary condition)
  2. Create a new singleplayer world with NeoForge and this mod
  3. Set up a simple villager breeding scenario: Place exactly 3 beds in an enclosure, spawn 2 villagers, give them a few stacks of bread to encourage them to breed
  4. Observe how breeding (after 10 seconds of heart particles) rightfully fails because the fail condition (in this case the gametime being less than 24000 ticks) is satisfied
  5. Set the gametime to anything higher than 24000 ticks, to make the condition no longer apply
  6. Observe how (after the villager breeding cooldown of 5 minutes has passed) the two villagers still cannot reproduce (this time with anger particles shown after the heart particles of the villager breeding process)

Description of issue:
When villager breeding is stopped through canceling the FinalizeSpawnEvent of the baby villager spawning, the relevant code in the VillagerMakeLove class does not account for the baby villager not actually being in the world and requests the one free bed in range to be reserved for the baby villager, even though the baby is not in the world. This lock of the bed POI (which can also happen repeatedly with multiple beds, if multiple free ones are pathfindable) will then prevent villagers from mating even if the relevant FinalizeSpawnEvent is no longer cancelled, due to the vanilla villager breeding logic not finding a free bed in range (even though at least one of the beds never had a villager sleeping in it, but was falsely marked as occupied by the cancelled first breeding process).
This can be fixed by breaking + replacing the wrongly occupied beds, however it is still an annoyance having to do that, since beds that will never be slept in should also logically allow villager breeding (everything else would be unintuitive).

@RedstoneDubstep RedstoneDubstep added the triage Needs triaging and confirmation label Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Needs triaging and confirmation
Projects
None yet
Development

No branches or pull requests

1 participant