Solved Setting durability help?

Discussion in 'Plugin Development' started by AaronL98, Jun 29, 2013.

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

    AaronL98

    I'm new to Bukkit, kinda new to java and I'm progressing, slowly :) Okay, so Im making a plugin when u right click with a hoe it fires a snowball and i want to decrease the hoe's durability by 2 every time a snowball is fired. Here's the code that is executed after a snowball is fired.
    Code:java
    1. Location loc = player.getLocation();
    2. short currentDurability = player.getItemInHand().getDurability();
    3. pi.getItemInHand().setDurability((short) (currentDurability - 2));
    4. player.updateInventory();


    This code does not seem to be setting the durability of the hoe. Please help me anyone :D
     
  2. Offline

    LucasEmanuel

    AaronL98
    The durability counts from zero up to maxdurability so you have you add instead of subtract.
     
  3. Offline

    AaronL98

    Thanks! Works perfectly
     
Thread Status:
Not open for further replies.

Share This Page