remove?

Discussion in 'Plugin Development' started by Bobfan, Nov 28, 2012.

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

    Bobfan

    Durring a test, I came to a problem: If you have an itemstack of 10 cobble, and you want to check if that player has 5 cobble, than it will say that the person doesn't have 5 cobble. I figured out if you split the 10 cobble into 2 stacks of 5, than it will except it. How would I get it to subtract 5 from the 10?
    Code:
    int material1 = Integer.parseInt(c.getString(nowQ + ".Fee.Item"));
    int amount1 = Integer.parseInt(c.getString(nowQ + ".Fee.Amount"));
    ItemStack i1 = new ItemStack(material1, amount1);
    if(in.contains(i1, 1) {
    [SIZE=11px][FONT=Monaco]in.removeItem(i1);[/FONT][/SIZE]
    So ignore the top 2, they just make up the itemstack. It won't remove 5 cobble from a stack of 10, how to fix?
     
  2. Offline

    EnvisionRed

    maybe something like this:
    Code:
    ItemStack cobble = someItemStack //arbitrary itemstack, you will get it in your own code
    if (cobble.getAmount() - 5 > -1){
    cobble.setAmount(cobble.getAmount() -5);
    }
     
Thread Status:
Not open for further replies.

Share This Page