How to set the item's durability right ?

Discussion in 'Plugin Development' started by JoshuaBehrens, Apr 25, 2011.

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

    JoshuaBehrens

    Hey guys,

    I want to change the item durability when some actions are done. I tried two ways but both don't work:

    Way 1:
    Code:
    p.getItemInHand().setDurability((short) (p.getItemInHand().getDurability() - 100));
    Way 2:
    Code:
    ItemStack item = p.getItemInHand(); // p instanceof Player
    item.setDurability((short) (item.getDurability() - 100));
    p.setItemInHand(item);
    Hope you can help and thanks in advanced.
     
  2. Offline

    Arrisar

    setDurability works the opposite way around, so if you would like to make an item take 100 uses, use '+100' instead
     
  3. Offline

    JoshuaBehrens

Thread Status:
Not open for further replies.

Share This Page