Jump to content

[Solved] Item break handler


McNutty

Recommended Posts

Is there a recommended/possible way to execute a function every time an item with durability breaks? I haven't been able to find an event that does this specifically, and it seems like checking item durability every tick would have a prohibitive runtime cost. To be clear, the Item itself won't be from my mod, so I can't override functions to accomplish this.

Link to comment
Share on other sites

Now I feel dumb. A week of searching Google, and I still couldn't find it.

 

Followup question, It seems that the event fires immediately before the ItemStack is deleted. What this means for me is that I can't replace the destroyed item with another because the replacement is deleted immediately after. Is there a way around this beyond adding the new item to another inventory slot? I want the player to be left holding the replacement item after the break occurs.

Link to comment
Share on other sites

Try searching your workspace.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I looked at all appearances of PlayerDestroyItemEvent, and nothing was relevant to my problem. According to a forum post and issue on Github, I'm not the only one struggling with this. I'll just use addItemStackToInventory instead. The only reason I'm doing this in the first place is to protect users from making a stupid mistake.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.