if (player != null) {
final ItemStack stack = new ItemStack(aID, aAmount, (short) 0, data);
final PlayerInventory inventory = player.getInventory();
final int maxStackSize = stack.getMaxStackSize();
if (stack.getAmount() <= maxStackSize)
inventory.addItem(stack);
final int amount = stack.getAmount();
final int quotient = amount / maxStackSize;
final int remainder = amount % maxStackSize;
for (int i = 0; i < quotient; i++)
inventory.addItem(new ItemStack(aID, maxStackSize, (short) 0, data));