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

Fix/Refactor VillagerEntity.canBreed and wantsToStartBreeding #4065

Open
wants to merge 2 commits into
base: 1.21.4
Choose a base branch
from

Conversation

Estecka
Copy link
Contributor

@Estecka Estecka commented Dec 3, 2024

The method VillagerEntity.canBreed returns true if the villager is unable to breed.
The method VillagerEntity.wantsToStartBreeding may sometimes return false even if the villager is willing to breed. It only returns true if the villager has twice over the amount of food required to start breeding.

In practice, these methods are only ever used to check whether two villagers should share food with each other. They're never used to trigger or prevent the actual breeding task. (The method used for that purpose is isReadyToBreed.)

I propose:
can(not)Breed -> needsFoodForBreeding
wantsToStartBreeding -> canShareFoodForBreeding

@Estecka
Copy link
Contributor Author

Estecka commented Dec 3, 2024

Just noticed that a lacksFood also exists so I renamed it to canEatFood to avoid confusion.

needsFoodForBreeding and canShareFoodForBreeding check the villager's inventory, whereas canEatFood checks the villager's "hunger bar", and is used to consume food from the inventory.

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