Jump to content

Recommended Posts

Posted

I need to respond when the player's armor or equipped weapons break, on the client side. 

 

I am aware of PlayerDestroyItemEvent, but that only triggers when a tool or weapon breaks while used on its intended material - it does not fire for armor, or eg. a pickaxe that breaks while mining sand. 

There's LivingEquipmentChangeEvent, but that also triggers when the player changes their armor on purpose, and doesn't cover tools or weapons.

I tried LivingAttackEvent, LivingHurtEvent, and LivingDamageEvent for the armor, but they also do not always fire when the player's armor breaks (for example, if the armor breaks due to a cactus but blocks all of the damage).

Lastly, monitoring the player's inventory every tick will also not work, because as with LivingEquipmentChangeEvent I can't distinguish between the armor/tools breaking and the player just unequipping/dropping it intentionally.

 

I did find ItemDurabilityTrigger, which appears to do exactly what I want (though I'm not sure about server/client side) ... but it's not an event, and therefore seems to require that I do some reflection/ASM stuff, which I am wary of.

 

Is there a way do this?

Posted

ItemDurabilityTrigger is an ICriterionTrigger for use with advancements.

There is not a Forge hook for this. But you could, conceivably, add a listener to the existing trigger, but keep in mind this is a server side effect only.

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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