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] LivingEntityUseItemEvent.Finish is not safe to grant advancements with rewards in #1501

Open
TelepathicGrunt opened this issue Aug 30, 2024 · 0 comments
Labels
1.21.1 Targeted at Minecraft 1.21.1 bug A bug or error

Comments

@TelepathicGrunt
Copy link
Contributor

TelepathicGrunt commented Aug 30, 2024

If you try to subscribe to this event to grant an advancements for some special case, any advancement item reward will be replaced with the item's consume remainder stack.

By that, I mean, look at the patched code:
image

Notice how finishUsingItem is ran first before the event. This will decrement the held stack. Lets say that stack is an item like 1 Honey Bottle. This will decrement it to an empty stack. Fire the event. If a mod then triggers an advancement that grants an item reward or the mod gives a new extra item to user (without replacing the useRemainder), the setItemInHand will replace that new item with the Glass Bottle remainder.

Making this event dangerous for adding extra items to the user. Perhaps we can adjust the setItemInHand line to check if hand is not empty and itemstack is not empty. Then move the held item in hand to a different spot in inventory and put itemstack remainder back into the hand. That way any item granted into hand in event is not deleted.

@TelepathicGrunt TelepathicGrunt added triage Needs triaging and confirmation bug A bug or error 1.21.1 Targeted at Minecraft 1.21.1 and removed triage Needs triaging and confirmation labels Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.21.1 Targeted at Minecraft 1.21.1 bug A bug or error
Projects
None yet
Development

No branches or pull requests

1 participant