Solved Get stack size from one specific slot.

Discussion in 'Spigot Plugin Development' started by Mondei1, Aug 22, 2017.

  1. Hey everybody,
    I have a problem.
    [​IMG]
    I want to get how many items stacked in slot 2 and so on...
    The only method that I know is the following:
    Code (Text):
    chestInv.getItem(1).getMaxStackSize();
    But it returns me only how many blocks can maximum stacked together, but I want to know how many currently stacked :(
    Must I use a for or while loop? Or is it much simpler?

    Can someone help me?
     
  2. try with ItemStack#getAmount()

    EDIT : @Trigary responded before me, I wasn't fast enough :(
     
    • Agree Agree x 1
  3. Every IDE when you write a method like getItem(i) and then you put a dot ("."), gives you suggestions. Please consider checking all of them before posting (Also, JavaDocs is your best friend in these situations) ! Not trying to be rude but, people don't even try these days.. Good Luck coding! :)
     
    • Agree Agree x 1
  4. Ohh, thanks to all for this quick awnser! It works!
     
  5. Also use common sense...
    getMaxSize() - dont u think that it would give the max not the amount stacked?
    Not trying to be mean