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

    NBTTagCompound altarCompound = new NBTTagCompound();
    altarCompound.setBoolean("isCrafting", this.isCrafting);
    altarCompound.setInteger("currentKey", this.currentKey);
    altarCompound.setString("currentSpellName", currentSpellName);

    NBTTagList allAddedItemsList = new NBTTagList();
    for (ItemStack stack : allAddedItems) {
      NBTTagCompound addedItem = new NBTTagCompound();
      stack.writeToNBT(addedItem);
      allAddedItemsList.appendTag(addedItem);
    }

    altarCompound.setTag("allAddedItems", allAddedItemsList);

    NBTTagList currentAddedItemsList = new NBTTagList();
    for (ItemStack stack : currentAddedItems) {
      NBTTagCompound addedItem = new NBTTagCompound();
      stack.writeToNBT(addedItem);
      currentAddedItemsList.appendTag(addedItem);
    }

    altarCompound.setTag("currentAddedItems", currentAddedItemsList);

    if (addedPhylactery != null) {
      NBTTagCompound phylactery = new NBTTagCompound();
      addedPhylactery.writeToNBT(phylactery);
      altarCompound.setTag("phylactery", phylactery);
    }

    if (addedBindingCatalyst != null) {
      NBTTagCompound catalyst = new NBTTagCompound();
      addedBindingCatalyst.writeToNBT(catalyst);
      altarCompound.setTag("catalyst", catalyst);
    }

    NBTTagList shapeGroupData = new NBTTagList();
    for (ArrayList<KeyValuePair<ISpellPart, byte[]>> list : shapeGroups) {
      shapeGroupData.appendTag(ISpellPartListToNBT(list));
    }
    altarCompound.setTag("shapeGroups", shapeGroupData);

    NBTTagCompound spellDefSave = ISpellPartListToNBT(this.spellDef);
    altarCompound.setTag("spellDef", spellDefSave);

    nbttagcompound.setTag("altarData", altarCompound);
  }
  @Override
  public void writeToNBT(NBTTagCompound nbttagcompound) {
    super.writeToNBT(nbttagcompound);
    NBTTagList nbttaglist = new NBTTagList();
    for (int i = 0; i < inventory.length; i++) {
      if (inventory[i] != null) {
        String tag = String.format("ArrayIndex", i);
        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
        nbttagcompound1.setByte(tag, (byte) i);
        inventory[i].writeToNBT(nbttagcompound1);
        nbttaglist.appendTag(nbttagcompound1);
      }
    }

    nbttagcompound.setTag("AstralBarrierInventory", nbttaglist);
  }
  @Override
  public void writeToNBT(NBTTagCompound nbttagcompound) {
    super.writeToNBT(nbttagcompound);
    NBTTagList nbttaglist = new NBTTagList();
    for (int i = 0; i < inventory.length; i++) {
      if (inventory[i] != null) {
        String tag = String.format("ArrayIndex", i);
        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
        nbttagcompound1.setByte(tag, (byte) i);
        inventory[i].writeToNBT(nbttagcompound1);
        nbttaglist.appendTag(nbttagcompound1);
      }
    }

    nbttagcompound.setTag("DeconstructorInventory", nbttaglist);

    nbttagcompound.setInteger("DeconstructionTime", current_deconstruction_time);
  }
  @Override
  public void writeToNBT(NBTTagCompound nbttagcompound) {
    super.writeToNBT(nbttagcompound);
    NBTTagList nbttaglist = new NBTTagList();
    for (int i = 0; i < inventory.length; i++) {
      if (inventory[i] != null) {
        String tag = String.format("ArrayIndex", i);
        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
        nbttagcompound1.setByte(tag, (byte) i);
        inventory[i].writeToNBT(nbttagcompound1);
        nbttaglist.appendTag(nbttagcompound1);
      }
    }

    nbttagcompound.setInteger("keystone_receptacle_dimension_id", worldObj.provider.dimensionId);
    nbttagcompound.setTag("KeystoneRecepticleInventory", nbttaglist);
    nbttagcompound.setBoolean("isActive", this.isActive);
  }