public void remove(ItemStack item) { int a = item.getAmount(); while (a > 0) { for (ItemStack is : slots) { if (is.getType().equals(item.getType())) { while (is.getAmount() > 0 && a > 0) { is.setAmount(is.getAmount() - 1); a--; } } } } }
public static void writeItem(NetOutput out, ItemStack item) throws IOException { if (item == null) { out.writeShort(-1); } else { out.writeShort(item.getId()); out.writeByte(item.getAmount()); out.writeShort(item.getData()); writeNBT(out, item.getNBT()); } }