Remove arrow from player's inventory

Discussion in 'Plugin Development' started by nuclearmissile, Aug 30, 2013.

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

    nuclearmissile

    I can't find the answer to this probably simple question. I need to remove an arrow from the player's inventory every time they fire a special weapon. I have the interact events and the projectile fire, I just can't figure out how to remove exactly one arrow from the inventory, like a vanilla bow. I use ItemStack, and it only recognizes a specific size stack of arrows. I use remove by ID, and it takes all of them. Help please?
     
  2. Offline

    xTrollxDudex

  3. Offline

    nuclearmissile

    The thing is, if I specify the ItemStack as Arrow, 1 it doesn't recognize larger stacks as a 1 arrow stack and doesn't remove them.
     
  4. Code:java
    1. itemstack.setAmount(itemstack.getamount - 1);

    That should work using the itemstack of arrows, if it doesn't then I've probably mis-spelt a method.
     
  5. Offline

    nuclearmissile

    Ok now I know that will work wizardo, but how do I identify a stack as a stack of arrows? It still specifies a specific amount of objects when using ItemStack.
     
  6. Offline

    nuclearmissile

  7. Offline

    nuclearmissile

  8. Offline

    nuclearmissile

    Guys seriously this isn't answered, how do I find the itemstack of arrows if it only recognizes that exact amount in a stack?
     
  9. Offline

    nuclearmissile

  10. Offline

    Deckerz

    For loop through the inventory and check if the items material is arrow and if it is break and remove one
     
Thread Status:
Not open for further replies.

Share This Page