Flint'n'steel durability

Discussion in 'Plugin Development' started by Venican, Aug 3, 2014.

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

    Venican

    Hello, look at this code. I have tried limiting the durablity to 4 uses but it goes down to 0 but is stuck there kind of.
    Code:java
    1. @EventHandler
    2. public void onFlintTakeAway(BlockPlaceEvent e)
    3. {
    4. Player player = e.getPlayer();
    5. Location playerLocation = player.getLocation();
    6. if ((e.getBlockPlaced().getType() == Material.FIRE) &&
    7. (player.getItemInHand().getType() == Material.FLINT_AND_STEEL))
    8. {
    9. player.getItemInHand().setDurability(new Integer(player.getItemInHand().getDurability() + 25).shortValue());
    10. player.playSound(playerLocation, Sound.ITEM_BREAK, 3.0F, 1.0F);
    11. }
    12. }
     
  2. Offline

    IkBenHarm

    Venican
    i dont understand, why you set the durabilty to the durability it has + 25?
     
  3. Try using the interact event and check if they right click on a block and if they hold flint and steel. And update the playerinventory by using player.updateInventory();

    This will make it go down faster (as he/she wants) and else it won't move.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  4. Offline

    Venican

    It works but when it breaks it just kind of replhanishes so it survives a few more places..

    Edit: I just tried making it so it +100 but it still survies lots of more places..
     
Thread Status:
Not open for further replies.

Share This Page