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)
Create a new singleplayer world with NeoForge and this mod
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
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
Set the gametime to anything higher than 24000 ticks, to make the condition no longer apply
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).
Minecraft Version: 1.21.1
NeoForge Version: 21.1.68
Steps to Reproduce:
FinalizeSpawnEvent
, and cancels it & callssetSpawnCancelled
on the event if the entity in the event is aVillager
, theMobSpawnType
isBREEDING
and the gametime is <24000 ticks (or any other arbitrary condition)Description of issue: When villager breeding is stopped through canceling the
FinalizeSpawnEvent
of the baby villager spawning, the relevant code in theVillagerMakeLove
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 relevantFinalizeSpawnEvent
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).