parent
4b51dbf062
commit
0620ea0d8a
|
|
@ -81,6 +81,8 @@ public class ItemChestChanger extends ItemTooltip
|
|||
|
||||
NonNullList<ItemStack> chestContents = NonNullList.<ItemStack> 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.<ItemStack> 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)
|
||||
|
|
|
|||
|
|
@ -130,6 +130,8 @@ public class ItemShulkerBoxChanger extends ItemTooltip
|
|||
NonNullList<ItemStack> shulkerBoxContents = NonNullList.<ItemStack> 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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue