diff --git a/src/main/java/cpw/mods/ironchest/common/items/chest/ItemChestChanger.java b/src/main/java/cpw/mods/ironchest/common/items/chest/ItemChestChanger.java index 8402c8f..627fa6d 100755 --- a/src/main/java/cpw/mods/ironchest/common/items/chest/ItemChestChanger.java +++ b/src/main/java/cpw/mods/ironchest/common/items/chest/ItemChestChanger.java @@ -81,6 +81,8 @@ public class ItemChestChanger extends ItemTooltip NonNullList chestContents = NonNullList. withSize(27, ItemStack.EMPTY); EnumFacing chestFacing = EnumFacing.DOWN; + boolean hasCustomName = false; + String customName = ""; if (te != null) { @@ -88,6 +90,13 @@ public class ItemChestChanger extends ItemTooltip { chestContents = ((TileEntityIronChest) te).getItems(); chestFacing = ((TileEntityIronChest) te).getFacing(); + + if (((TileEntityIronChest) te).hasCustomName()) + { + hasCustomName = true; + customName = ((TileEntityIronChest) te).getName(); + } + newchest = this.type.target.makeEntity(); if (newchest == null) @@ -110,6 +119,12 @@ public class ItemChestChanger extends ItemTooltip return EnumActionResult.PASS; } + if (chest.hasCustomName()) + { + hasCustomName = true; + customName = chest.getName(); + } + chestContents = NonNullList. withSize(chest.getSizeInventory(), ItemStack.EMPTY); for (int i = 0; i < chestContents.size(); i++) @@ -144,6 +159,11 @@ public class ItemChestChanger extends ItemTooltip { ((TileEntityIronChest) te2).setContents(chestContents); ((TileEntityIronChest) te2).setFacing(chestFacing); + + if (hasCustomName) + { + ((TileEntityIronChest) te2).setCustomName(customName); + } } if (!playerIn.capabilities.isCreativeMode) diff --git a/src/main/java/cpw/mods/ironchest/common/items/shulker/ItemShulkerBoxChanger.java b/src/main/java/cpw/mods/ironchest/common/items/shulker/ItemShulkerBoxChanger.java index ce22c4a..6111f35 100644 --- a/src/main/java/cpw/mods/ironchest/common/items/shulker/ItemShulkerBoxChanger.java +++ b/src/main/java/cpw/mods/ironchest/common/items/shulker/ItemShulkerBoxChanger.java @@ -130,6 +130,8 @@ public class ItemShulkerBoxChanger extends ItemTooltip NonNullList shulkerBoxContents = NonNullList. withSize(27, ItemStack.EMPTY); EnumFacing shulkerBoxFacing = EnumFacing.UP; EnumDyeColor shulkerBoxColor = EnumDyeColor.PURPLE; + boolean hasCustomName = false; + String customName = ""; if (te != null) { @@ -140,6 +142,12 @@ public class ItemShulkerBoxChanger extends ItemTooltip shulkerBoxColor = getColorFromTileEntity(te, worldIn); ((TileEntityIronShulkerBox) te).setHasBeenUpgraded(); + if (((TileEntityIronShulkerBox) te).hasCustomName()) + { + hasCustomName = true; + customName = ((TileEntityIronShulkerBox) te).getName(); + } + newShulkerBox = this.type.target.makeEntity(shulkerBoxColor); if (newShulkerBox == null) @@ -165,6 +173,12 @@ public class ItemShulkerBoxChanger extends ItemTooltip shulkerBoxContents.set(i, shulkerBox.getStackInSlot(i)); } + if (shulkerBox.hasCustomName()) + { + hasCustomName = true; + customName = shulkerBox.getName(); + } + shulkerBoxColor = getColorFromTileEntity(te, worldIn); shulkerBox.clear(); @@ -202,6 +216,11 @@ public class ItemShulkerBoxChanger extends ItemTooltip { ((TileEntityIronShulkerBox) te2).setContents(shulkerBoxContents); ((TileEntityIronShulkerBox) te2).setFacing(shulkerBoxFacing); + + if (hasCustomName) + { + ((TileEntityIronShulkerBox) te2).setCustomName(customName); + } } if (!playerIn.capabilities.isCreativeMode) diff --git a/src/main/java/cpw/mods/ironchest/common/tileentity/chest/TileEntityIronChest.java b/src/main/java/cpw/mods/ironchest/common/tileentity/chest/TileEntityIronChest.java index bbdb9fd..eb01208 100755 --- a/src/main/java/cpw/mods/ironchest/common/tileentity/chest/TileEntityIronChest.java +++ b/src/main/java/cpw/mods/ironchest/common/tileentity/chest/TileEntityIronChest.java @@ -598,7 +598,19 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick public NBTTagCompound getUpdateTag() { NBTTagCompound compound = super.getUpdateTag(); + + if (!this.checkLootAndWrite(compound)) + { + ItemStackHelper.saveAllItems(compound, this.chestContents); + } + compound.setByte("facing", (byte) this.facing.ordinal()); + + if (this.hasCustomName()) + { + compound.setString("CustomName", this.customName); + } + return compound; } diff --git a/src/main/java/cpw/mods/ironchest/common/tileentity/shulker/TileEntityIronShulkerBox.java b/src/main/java/cpw/mods/ironchest/common/tileentity/shulker/TileEntityIronShulkerBox.java index f18ac19..4525015 100644 --- a/src/main/java/cpw/mods/ironchest/common/tileentity/shulker/TileEntityIronShulkerBox.java +++ b/src/main/java/cpw/mods/ironchest/common/tileentity/shulker/TileEntityIronShulkerBox.java @@ -686,7 +686,25 @@ public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements public NBTTagCompound getUpdateTag() { NBTTagCompound compound = super.getUpdateTag(); + + if (!this.checkLootAndWrite(compound)) + { + ItemStackHelper.saveAllItems(compound, this.items, false); + } + + compound.setInteger("ShulkerBoxSize", this.getSizeInventory()); + compound.setByte("facing", (byte) this.facing.ordinal()); + + if (this.hasCustomName()) + { + compound.setString("CustomName", this.customName); + } + + if (!compound.hasKey("Lock") && this.isLocked()) + { + this.getLockCode().toNBT(compound); + } return compound; }