private static int getStackAmount(ItemStack item, Inventory inventory, Player player, Action action) {
Action buy = Properties.REVERSE_BUTTONS ? LEFT_CLICK_BLOCK : RIGHT_CLICK_BLOCK;
Inventory checkedInventory = (action == buy ? inventory : player.getInventory());
if (checkedInventory.containsAtLeast(item, item.getMaxStackSize())) {
return item.getMaxStackSize();
} else {
return InventoryUtil.getAmount(item, checkedInventory);
}
}