@Override
  public void writeToNBT(NBTTagCompound data) {
    super.writeToNBT(data);

    NBTTagList itemList = new NBTTagList();
    NBTTagList sideItemList = new NBTTagList();
    NBTTagCompound configData;

    data.setBoolean("shareRS", isRSShared);

    for (int i = 0; i < 3; i++) {

      if (inventory.getStackInSlot(i) != null) {
        NBTTagCompound itemCompound = new NBTTagCompound();
        itemCompound.setInteger("slot", i);
        inventory.getStackInSlot(i).writeToNBT(itemCompound);
        itemList.appendTag(itemCompound);
      }

      if (tanks[i].getFluid() != null) {
        data.setInteger("tankCap" + i, tanks[i].getCapacity());
        data.setTag("Fluid" + i, tanks[i].getFluid().writeToNBT(new NBTTagCompound()));
      }

      data.setBoolean("rsControl" + i, rsControl[i]);
      data.setBoolean("rsLatch" + i, rsLatch[i]);
    }

    data.setTag("items", itemList);

    for (int i = 0; i < 6; i++) {
      data.setInteger("side" + i, sides[i]);
      configData = new NBTTagCompound();
      configs[i].writeToNBT(configData);
      data.setCompoundTag("config" + i, configData);
      data.setBoolean("rs" + i, sideRS[i]);
      data.setBoolean("lock" + i, sideLocked[i]);
      data.setInteger("facID" + i, facID[i]);
      data.setInteger("facMeta" + i, facMeta[i]);

      if (sideInventory.getStackInSlot(i) != null) {
        NBTTagCompound itemCompound = new NBTTagCompound();
        itemCompound.setInteger("slot", i);
        sideInventory.getStackInSlot(i).writeToNBT(itemCompound);
        sideItemList.appendTag(itemCompound);
      }
    }

    data.setTag("sideItems", sideItemList);

    if (capacitor != null) {
      data.setInteger("realPower", capacitor.getEnergyStored());
      capacitor.writeToNBT(data);
      data.setInteger("powerCap2", capacitor.getMaxEnergyStored());
    }
  }
 @Override
 public void writeToNBT(NBTTagCompound tagCompound) {
   super.writeToNBT(tagCompound);
   if (link != null) {
     NBTTagCompound linkTag = new NBTTagCompound();
     link.writeToNBT(linkTag);
     tagCompound.setTag("link", linkTag);
   }
   tagCompound.setBoolean("noEnergy", noEnergy);
   storage.writeToNBT(tagCompound);
 }
 @Override
 public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) {
   super.writeCustomNBT(nbt, descPacket);
   nbt.setInteger("facing", facing);
   NBTTagCompound tankTag = tank0.writeToNBT(new NBTTagCompound());
   nbt.setTag("tank0", tankTag);
   tankTag = tank1.writeToNBT(new NBTTagCompound());
   nbt.setTag("tank1", tankTag);
   tankTag = tank2.writeToNBT(new NBTTagCompound());
   nbt.setTag("tank2", tankTag);
   energyStorage.writeToNBT(nbt);
   if (!descPacket) {
     nbt.setTag("inventory", Utils.writeInventory(inventory));
   }
 }
  @Override
  public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) {
    super.writeCustomNBT(nbt, descPacket);
    nbt.setInteger("facing", facing);
    energyStorage.writeToNBT(nbt);

    NBTTagCompound tankTag = tank.writeToNBT(new NBTTagCompound());
    nbt.setTag("tank", tankTag);

    nbt.setTag("inventory", Utils.writeInventory(inventory));

    nbt.setTag("predictedOutput", Utils.writeInventory(predictedOutput));

    nbt.setIntArray("process", process);
  }
  @Override
  public void writeToNBT(NBTTagCompound nbt) {
    super.writeToNBT(nbt);
    storage.writeToNBT(nbt);

    NBTTagCompound laser = new NBTTagCompound();
    laserSat.writeToNBT(laser);

    nbt.setTag("laser", laser);

    NBTTagList list = new NBTTagList();
    NBTTagList itemList = new NBTTagList();
    /*for(int i = 0; i < invBuffer.length; i++)
    {
    	ItemStack stack = invBuffer[i];
    	if(stack != null) {
    		NBTTagCompound tag = new NBTTagCompound();
    		tag.setByte("Slot", (byte)(i));
    		stack.writeToNBT(tag);
    		itemList.appendTag(tag);
    	}
    }
    nbt.setTag("InventoryBuffer", itemList);*/

    if (glassPanel != null) {
      NBTTagCompound tag = new NBTTagCompound();
      glassPanel.writeToNBT(tag);
      nbt.setTag("GlassPane", tag);
    }

    nbt.setInteger("laserX", laserX);
    nbt.setInteger("laserZ", laserZ);
    nbt.setByte("mode", (byte) mode.ordinal());

    if (mode == MODE.SPIRAL) {
      nbt.setInteger("CenterX", xCenter);
      nbt.setInteger("CenterY", yCenter);
      nbt.setInteger("radius", radius);
      nbt.setInteger("numSteps", numSteps);
      nbt.setInteger("prevDir", prevDir.ordinal());
    }
  }
 @Override
 public void writeNBT(NBTTagCompound tagCompound) {
   tagCompound.setBoolean("isRunning", isRunning);
   tagCompound.setInteger("facing", facing.ordinal());
   storage.writeToNBT(tagCompound);
 }
 @Override
 public void writeToNBT(NBTTagCompound nbt) {
   super.writeToNBT(nbt);
   storage.writeToNBT(nbt);
 }