Example #1
0
  @Override
  public void writeToNBT(NBTTagCompound nbt) {
    super.writeToNBT(nbt);
    nbt.setDouble("EMC", this.getStoredEMC());
    nbt.setShort("BurnTime", (short) furnaceBurnTime);
    nbt.setShort("CookTime", (short) furnaceCookTime);

    NBTTagList list = new NBTTagList();
    for (int i = 0; i < getSizeInventory(); i++) {
      if (inventory[i] == null) continue;
      NBTTagCompound subNBT = new NBTTagCompound();
      subNBT.setByte("Slot", (byte) i);
      inventory[i].writeToNBT(subNBT);
      list.appendTag(subNBT);
    }
    nbt.setTag("Items", list);
  }
Example #2
0
  @Override
  public void readFromNBT(NBTTagCompound nbt) {
    super.readFromNBT(nbt);
    this.setEmcValue(nbt.getDouble("EMC"));
    furnaceBurnTime = nbt.getShort("BurnTime");
    furnaceCookTime = nbt.getShort("CookTime");
    currentItemBurnTime = getItemBurnTime(inventory[0]);

    NBTTagList list = nbt.getTagList("Items", 10);
    inventory = new ItemStack[getSizeInventory()];
    for (int i = 0; i < list.tagCount(); i++) {
      NBTTagCompound subNBT = list.getCompoundTagAt(i);
      byte slot = subNBT.getByte("Slot");
      if (slot >= 0 && slot < getSizeInventory())
        inventory[slot] = ItemStack.loadItemStackFromNBT(subNBT);
    }
  }