Paper icon indicating copy to clipboard operation
Paper copied to clipboard

InventoryClickEvent gives InventoryAction.NOTHING when getting a custom result from an anvil

Open Xeonmeister opened this issue 3 years ago • 0 comments

Expected behavior

So i have a plugin where you can put a knowledge book in an anvil and it gets all the enchantments from the second item put in, so the result is the green book with the second item's enchants. With the PrepareAnvilEvent i set this new enchanted knowledge book as the result and i set a custom repair cost in the anvilinventory.

In theory when i get the item out of the anvil i should get InventoryAction.PICKUP_ALL from the InventoryClickEvent, i should not be able to take the book out if i dont have enough levels and if i do then the levels should be taken.

Observed/Actual behavior

Even though i hear the anvil sounds when i take the result out i get InventoryAction.NOTHING from InventoryClickEvent, my experience remains untouched and i can take the result out even if i dont have enough levels. The knowledge book that i get from the anvil remains in the inventory, so it's not just visual, i really get the result from the anvil.

When the knowledge book result is taken from the anvil it seems like it removes the levels from the player but after teleportation or any xp change (killing a mob or picking up any xp source) it shows the correct xp value.

Steps/models to reproduce

In the PrepareAnvilEvent check if the first item is a knowledge book and if the seconds item has any enchants. If this is true then set the result to be a knowledge book with the second item's enchants. (I think this is optional) Set a custom repair cost. Check the InventoryAction when you get the item out of the anvil. You get the item but it says it's inventoryAction.NOTHING.

Plugin and Datapack List

"my plugin using the PrepareAnvilEvent", Protocollib, Multiverse, VoidGen, Vault, WorldEdit, Squaremap

Paper version

git-Paper-125 (MC: 1.19.2)

Other

No response

Xeonmeister avatar Aug 11 '22 16:08 Xeonmeister