code: public int setItemStackSize(int stackSize)
  	{
  		if (itemStack.isEmpty())
  			return 0;
  
  		int start = itemStack.getCount();
  		itemStack.setCount(Math.min(stackSize, Math.min(itemStack.getMaxStackSize(), getSlotStackLimit())));
  		return itemStack.getCount() - start;
  	}
docs: Sets the item stack size.
  
  @param stackSize the stack size
  @return the amount of items that were added to the slot.