Using the Unbreakable attribute

Discussion in 'Plugin Development' started by MineCrypt, Jun 24, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    MineCrypt

    Hey there, so back in the release of Minecraft 1.6 they added new attributes to armour and weapons, including speed, health and even potion effects. But I can't remember if it's in 1.6 or 1.7 but they added an "Unbreakable" attribute. Making it so armour and weapons simply don't use durability. How can I add this to my armour/weapons?

    Edit: I'm looking for a simple way that requires no reflection/NMS, one that is at least non-Version Dependent and up to date.
     
  2. Offline

    fireblast709

    MineCrypt too bad, nonexistant atm :p (at least not as fluent as with the tag). The only thing you can do is using either the PlayerItemBreakEvent to cancel it, check all events that decrease durability and work from there, or have a runnable that runs every tick, updating damaged items.
     
  3. Offline

    teej107

    fireblast709 MineCrypt Would doing setDurabilty(Short.MAX_VALUE) work? Or would it just set the durability to 32767 (2^15-1)?
     
  4. Offline

    Plo124

    teej107
    Setting the durability to 0 means no damage taken to it.
    If you want to get the max durability of an item, you can go itemStack.getType().getMaxDurability()
     
  5. Offline

    teej107

    Plo124 Ah ok. I never used that method before.
     
  6. Offline

    Garris0n

Thread Status:
Not open for further replies.

Share This Page