Solved Drop one Item out of a whole stack

Discussion in 'Plugin Development' started by VortexGmer, Apr 18, 2015.

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

    VortexGmer

    How do I drop One item out of an Item Stack? Right now it just drops the whole 64! I want it to drop only 1. Here is my code:
    Code:
                            ItemStack  dropped = p.getWorld().dropItem(p.getLocation(), p.getItemInHand()).getItemStack();
                            p.getInventory().removeItem(dropped);
     
  2. @VortexGmer Set the itemstack but have the amount 1 less.
     
  3. Offline

    VortexGmer

    How?
     
  4. Offline

    nverdier

    @VortexGmer ItemStack#setAmount(int amount) and just pass it the current amount - 1.
     
  5. Offline

    Zombie_Striker

    Do this
    Code:
    ItemStack is = itemstack;
    int amount = player.getItem().getAmount() - 1;
    is.setAmount(amount);
    player.getItem().setAmount(1);
     
Thread Status:
Not open for further replies.

Share This Page