ItemStack Help

Discussion in 'Plugin Development' started by Pizza371, Aug 26, 2013.

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

    Pizza371

    How do I remove a certain amount of itemstack from a player?
    E.G.
    I defined an itemstack which gives 1
    then I want to take 45 of that item when someone buys something, how (it needs to be that specific itemstack)?
    Thanks!
     
  2. Offline

    boss86741

    Not sure. I know that there is p.getInventory().remove(new ItemStack(Material.ITEM))
     
  3. Offline

    Pizza371

    boss86741 yea but I need to remove a certain amount :(
    Could do a while loop, but I would prefer it if there was a normal method.. I would of thought there would be
    while (int x < amt to take) {
    inv.remove(item)
    }
    hmm..
     
  4. p.getInventory().remove(new ItemStack(Material.ITEM,amount));
     
  5. Offline

    Compressions

    Pizza371 Loop through inv contents, check if inv contains certain item, set amount of item to x.
     
  6. Offline

    xTrollxDudex

    Pizza371
    Make sure the inventory containsAtLeast(...) the item and use ShadowNinja's method
     
  7. Offline

    Pizza371

    xTrollxDudex Compressions XxShadow_NinjaxxX
    I can't use that method because i cant make an itemstack with an already existing itemstack
    Not entirely sure how to get a specific item inside an inventory and change its amount
    I need something like this:
    Code:
        if(p.getInventory().contains(itemstack, 40)) {
                        p.getInventory().removeItem(itemstack, amount);
    but another way of doing that, since I can't do it that way
     
  8. Offline

    Compressions

     
Thread Status:
Not open for further replies.

Share This Page