A little question for you NEED HELP

Discussion in 'Plugin Development' started by mikeaaaa, Jul 21, 2013.

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

    mikeaaaa

    Is it possible to set on a Blazerod durability?

    And, when the durability is 0 , that the item will disapear?
    Thanks :D

    My English is not the yellow of the Egg ;D
     
  2. Offline

    etaxi341

    mikeaaaa No it is not. You could use the Lore of the Item and display a Durability there but it's not possible with this green line under the Item.
     
  3. Offline

    Alex5657

    ▒▒

    Put this in the lore and track attack/block break events, then change the amount of boxes and a the durability variable.
    Once it runs out, delete the item from the inventory
     
  4. Offline

    mikeaaaa

    And, how can I make that the Item disapear when it is use once, but you can't use it twice?
    That means, you only can use it 1 time, then the item disapears

    @EventHandler
    public void Drugs(PlayerInteractEvent event){
    Player p = event.getPlayer();

    if (event.getAction() == Action.RIGHT_CLICK_AIR && (p.getItemInHand().getTypeId() == 402)){
    p.launchProjectile(Snowball.class);

    }else{

    }
    }


    I would like, that after 1 right click, the item (blazerod) disapers

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  5. Code:java
    1. @EventHandler
    2. public void Drugs(PlayerInteractEvent event){
    3. Player p = event.getPlayer();
    4.  
    5. if (event.getAction() == Action.RIGHT_CLICK_AIR && (p.getItemInHand().getTypeId() == 402)){
    6. p.launchProjectile(Snowball.class);
    7.  
    8. }else{
    9. }
    10. }
    11.  

    If this is your code now, then maybe try doing this?:
    Code:java
    1. @EventHandler
    2. public void Drugs(PlayerInteractEvent event){
    3. Player p = event.getPlayer();
    4.  
    5. if (event.getAction() == Action.RIGHT_CLICK_AIR && (p.getItemInHand().getTypeId() == 402)){
    6. p.launchProjectile(Snowball.class);
    7. e.getPlayer().getItemInHand().setDurability((short) 0);
    8. }else{
    9. }
    10. }

    You can change the 0 to whatever durability you want. Test it out and let me know if it works, because I haven't actually used that bit of code in my plugins.
     
  6. Offline

    mikeaaaa

    No sorry, it dont work
     
  7. Offline

    Tarestudio

    mikeaaaa
    Get the ItemStack with e.getPlayer().getItemInHand(), check if there is more then 1 item in stack, if reduce by one, else set ItemStack to null
     
  8. Lol, that's cause I didn't add vital code. Here is what you need:
    Code:java
    1. @EventHandler
    2. public void Drugs(PlayerInteractEvent event){
    3. Player p = event.getPlayer();
    4.  
    5. if (event.getAction() == Action.RIGHT_CLICK_AIR && (p.getItemInHand().getTypeId() == 402)){
    6. p.launchProjectile(Snowball.class);
    7. e.getPlayer().getItemInHand().setDurability((short) 0);
    8. if (player.getInventory().getItemInHand().getDurability() == 0)
    9. player.getInventory().remove(407);
    10. }
    11. }
    12. }

    That should work! Let me know if it does. If so, then don't hesitate to give da' man a like. :D
     
Thread Status:
Not open for further replies.

Share This Page