コード例 #1
0
ファイル: PlayerInventory.java プロジェクト: jhead/Starfury
  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--;
          }
        }
      }
    }
  }
コード例 #2
0
ファイル: NetUtil.java プロジェクト: yawkat/MCProtocolLib
 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());
   }
 }