Solved Removing item from inventory

Discussion in 'Plugin Development' started by Gorbit99, Nov 27, 2015.

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

    Gorbit99

    I'm creating a plugin, where when you click an item in your inventory, it gets into an other one. I'm doing this by spawning the item in the other inventory, then removing 1 from the amount of items. The problem is, whne there's only 1 item. The item gets into the GUI, but it won't get deleted. How could I fix that?

    -Gorbit99
     
  2. Offline

    Xerox262

    Check if the amount is 1, then rather than setting the amount to 0 set the slot to empty.
     
  3. Offline

    Zombie_Striker

    @Gorbit99
    If the amount you're setting the item to is less than 1, the itemstack will set the amount back to 1. You need to check if the amount it would be if you removed 1 would be less than 1, and if so, use Inventory.remove(the Itemstack instance).

    BTW. A simple google search would have given you the answer.
     
  4. Offline

    Gorbit99

    Tried that, that's the problem
    "Use .remove()" every single time
    Will try that, thanks

    Ok, I used inventory.clear(int) instead

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 27, 2015
Thread Status:
Not open for further replies.

Share This Page