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

Pollidisiac feeds flowers to brown mooshrooms #4521

Conversation

TheRealWormbo
Copy link
Collaborator

Also includes smaller optimizations to the finding and feeding logic:

  • don't look for anything if out of mana
  • exclude items from the search that can't be interacted with
  • don't look for animals when no items are around
  • exclude animals from the search that would not be fed anyway because they are a baby, or already in the mood and not a brown mooshroom

break;
// Note: Empty item stacks are implicitly excluded in Animal::isFood and ItemStack::is(TagKey)
if (!animal.isInLove()) {
for (ItemEntity item : items) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite sure this works as intended. Won't this consume multiple items on one animal? There's nothing that breaks out of the loop once a food item has been consumed from what i can see.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, that item loop was definitely missing a break.

Copy link
Member

@artemisSystem artemisSystem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a comment inline, as i don't think the code is quite sound.

Also includes smaller optimizations to the finding and feeding logic:
* don't look for anything if out of mana
* exclude items from the search that can't be interacted with
* don't look for animals when no items are around
* exclude animals from the search that would not be fed anyway because they are a baby, or already in the mood and not a brown mooshroom
@TheRealWormbo TheRealWormbo force-pushed the 1.20-pollidisiac-suspicious-flowers branch from 8112d39 to b80a5b1 Compare December 30, 2023 13:32
@artemisSystem
Copy link
Member

I didn't test this, but i assume you did, and the code looks fine now. Thanks!

@artemisSystem artemisSystem merged commit df5cc65 into VazkiiMods:1.20.x Dec 30, 2023
1 check passed
@TheRealWormbo
Copy link
Collaborator Author

I didn't test this, but i assume you did, and the code looks fine now. Thanks!

I did, only missing the multiple item entities case earlier.

@artemisSystem
Copy link
Member

Wonderful!

@TheRealWormbo TheRealWormbo deleted the 1.20-pollidisiac-suspicious-flowers branch December 30, 2023 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants