Get count of certain item in inventory and taking

Discussion in 'Plugin Development' started by bars96, May 13, 2015.

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

    bars96

    Don't work.
    type = material
    am = amount
    me = meta-data
    Code:
                if (!p.getInventory().contains(new ItemStack(type, am, me))) {
                    // If player has no fuel
                    p.sendMessage(msg("not-enough-fuel"));
                    e.setCancelled(true);
                    p.setFlying(false);
                    return;
                } else
                    p.getInventory().removeItem(new ItemStack(type, am, me));
    I also tried this, but it not work too:
    Code:
    if (!p.getInventory().containsAtLeast(new ItemStack(type, am, me), am))
     
  2. Offline

    Zombie_Striker

    player#updateInventory

    Also, look into setting the amount to be getamount - 1 instead of removeing the whole itemstack like you are.
     
  3. Offline

    bars96

    "removeItem" instead of "remove" doesn't remove whole ItemStack, I checked it even on 1.5.2

    Solved

    EDIT by Timtower: merged posts
     
    Last edited by a moderator: May 14, 2015
Thread Status:
Not open for further replies.

Share This Page