public int getAmount(Player arg0, ItemStack arg1) { if (arg1 == null) return 0; int amount = 0; for (int i = 0; i < 36; i++) { ItemStack slot = arg0.getInventory().getItem(i); if (slot == null || !slot.isSimilar(arg1)) continue; amount += slot.getAmount(); } return amount; }