#change a item max durability

6 messages · Page 1 of 1 (latest)

mighty isle
#

i want to have items durability change depending on what nbt data the item has but idk how to change durability outside of startup

lime ivyBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

keen warren
mighty isle
#

Hmm then is there a way I can make a item take more or less damage from mining/attack

keen warren
# mighty isle i want to have items durability change depending on what nbt data the item has b...

A workaround is to change the damage value when leftclick

BlockEvents.rightClicked("bedrock", event => {
    const {player, hand} = event
    if(hand == "off_hand") return;
    player.give(Item.of("minecraft:netherite_axe").withNBT({"max_durability": 10}))
})

ItemEvents.firstLeftClicked(event => {
    const {item} = event
    if(!item.damageableItem) return;
    const leastDamageValue = item.maxDamage - (item.nbt?.max_durability || 0)
    if(item.damageValue < leastDamageValue) item.setDamageValue(leastDamageValue)
})
mighty isle
#

thanks this should work🙏