Started by
MamaLuigi
on
Topic category: Help with modding (Java Edition)
The title explains itself, how do i detect when the item the player is holding lost durability?
For example, if the player is holding an Iron Pickaxe, and the pickaxe lost 1 point of durability, how would i be able to detect that?
I don't know if there's a way to detect this directly, but you could keep in mind that there's a limited number of ways items can lose durability. Pickaxes, for example, only ever lose durability when they break blocks or hit things. (This is slightly random though, and gets more complicated with enchantments and things.)
...It's possible you could try creating a custom number NBT tag that applies to an item, keeping track of the item's last durability. Then, if the item's current durability no longer matches the NBT tag, you know that durability has changed, and can update the NBT tag. I'm not how sure if this would work well, but it's worth a try.