[SPIGOT-3144] PrepareAnvilEvent does not always fire. Created: 23/Mar/17  Updated: 24/Mar/17  Resolved: 24/Mar/17

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: William Gaylord Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: Event
Environment:

Windows 10

java 1.80_111

Spigot This server is running CraftBukkit version git-Spigot-7d78b81-e232e15 (MC: 1.11.2) (Implementing API version 1.11.2-R0.1-SNAPSHOT) 

 

Yes I know its way out of data. But the event should still work properly...



 Description   

The PrepareAnvilEvent only fires for items that will actually work in an anvil.

I expected it work fire when you place any item is in the anvil not just valid items. (Allowing for custom use of the anvil or in my case allow for enchanting blocks in survival.)

If this is not the case the docs should state this.



 Comments   
Comment by md_5 [ 24/Mar/17 ]

<chibill> http://pastebin.com/XZJScKFf
<~md_5> [15:27:37 INFO]: ItemStack

{SADDLE x 1}

<~md_5> [15:27:37 INFO]: ItemStack

{SAND x 4}

<~md_5> works for me
<~md_5> => still cannot reproduce
<chibill> IF you place any item that is not normally valid in an anvil into the first slot and then say an enchanted book it will show null
<chibill> SO just because you code is magic does not mean it can't be reproduced...
<~md_5> [15:28:26 INFO]: ItemStack

{SAND x 9}

<~md_5> [15:28:26 INFO]: ItemStack

{ENCHANTED_BOOK x 1}

<chibill> I have proof... I can event record it...
<~md_5> using literally the exact code you pasted above

Comment by William Gaylord [ 24/Mar/17 ]

Tell me how that is not broken.

Comment by William Gaylord [ 24/Mar/17 ]

Example.

You jsut print the contents of the inventory slots.

You insert one item that is say a stone block. It prints

STONE

null

null

 

you insert  an enchanted book into the second slot it prints

STONE

null

null

again when it should print

STONE

BOOK

null

Comment by William Gaylord [ 24/Mar/17 ]

Do i have to give you code that prove my point?

Comment by William Gaylord [ 24/Mar/17 ]

this https://bukkit.org/threads/how-to-put-unsafe-enchantments-to-result-item-in-anvil.412472/#post-3350913 use to work. 

But because of this bug it no longer works. In which one of the items in the slots are always null. (The one you put in last).. 

Comment by William Gaylord [ 24/Mar/17 ]

I don't want the item clicked I want to know what they put in the anvil. 

 SO I guess this is another bug that won't be addressed. (Like how onpalce can give you a null instead of the placed block randomly..)

As for number 2 If this is true then why did it work before? Back in march of 2016?

Comment by md_5 [ 24/Mar/17 ]

1) The event always fires (tested using sand)
2) Yes this is correct because of what the PrepareEvent is. If you want to get the item specifically you should use InventoryClickEvent
3) You can set the result - this works fine (tested using diamond), although sometimes an update may be required.
4) You can't remove invalid results from the inventory - this is a client limitation.

Ultimately the restrictions on this event are the product of the client and the event as is is the best result I think we can give.

Comment by William Gaylord [ 23/Mar/17 ]

Okay So I have how found that the actual problem is you can't actually see what item got put in that triggered the event. 

And setting the event result does nothing. (But make it impossible to use the anvil)

Comment by William Gaylord [ 23/Mar/17 ]

I need to experiment with this bug to find what exactly is happening.

Comment by William Gaylord [ 23/Mar/17 ]

Never Mind.. Its not that its not called its that the item that caused it does not show up in the inventory in the event... (It also is not passed by the event)

 

It also appears that event if you set the result it will not display the item if it is normally not able to be used in the anvil.

Generated at Wed Dec 17 19:55:17 UTC 2025 using Jira 10.3.15#10030015-sha1:909cc43d292ca09e774c1a243d9819be3f2628cd.