Detect when item takes damage?

Started by MamaLuigi on

Topic category: Help with modding (Java Edition)

Last seen on 03:24, 24. Feb 2024
Joined Sep 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Detect when item takes damage?

I would like to make it so if the item in either your main hand, off hand, helmet slot, chestplate slot, leggings slot, or boots slot takes damage, the player will explode

 

I tried making a procedure with the global trigger "Player finishes using item", but it didn't work

 

Any help would be greatly appreciated!

Last seen on 21:55, 20. Feb 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
There isn't a trigger for…
Thu, 11/02/2023 - 03:37

There isn't a trigger for durability loss, but there's a very limited number of situations where durability goes down. For armor, durability only ever goes down when the player is attacked and the armor absorbs damage, and for items, the durability only ever goes down when the player mines a block or hits something with an item. You could essentially use the 'before entity is hurt,' and 'block is broken' global triggers, combined with an if statement that checks if the player is wearing your custom armor/using your tool/the source entity about to hurt the target entity is using your tool. It's a little bit more complicated than that, (durability decrease is slightly randomized), but unless you need this to be really precise for some reason, you could use a 'do with 70% chance' procedure template, or something along those lines, to get the same effect.

'Player Finishes Using item' is only for items that have a use animation, such as foods, bows, tridents, etc; which is why it probably wasn't working.

...Also, I can't help but ask, what sort of items are you designing that, uh, explode the player whenever they lose durability?