Made it so that replaced chests from mimics keep their inventory and when broken will drop their inventory.

This commit is contained in:
WayofTime 2016-08-23 17:53:33 -04:00
parent 0420779e5e
commit 1adbe04ab8
2 changed files with 27 additions and 0 deletions

View file

@ -59,6 +59,14 @@ public class ItemBlockMimic extends ItemBlock
// ItemStack replacedStack = new ItemStack(block, 1, block.getMetaFromState(iblockstate));
NBTTagCompound tileTag = getTagFromTileEntity(tileReplaced);
if (tileReplaced != null)
{
NBTTagCompound voidTag = new NBTTagCompound();
voidTag.setInteger("x", pos.getX());
voidTag.setInteger("y", pos.getY());
voidTag.setInteger("z", pos.getZ());
tileReplaced.readFromNBT(voidTag);
}
if (placeBlockAt(stack, player, world, pos, facing, hitX, hitY, hitZ, iblockstate1))
{
@ -71,6 +79,7 @@ public class ItemBlockMimic extends ItemBlock
{
TileMimic mimic = (TileMimic) tile;
mimic.metaOfReplacedBlock = block.getMetaFromState(iblockstate);
mimic.tileTag = tileTag;
mimic.setInventorySlotContents(0, replacedStack);
mimic.refreshTileEntity();
@ -81,6 +90,9 @@ public class ItemBlockMimic extends ItemBlock
}
return EnumActionResult.SUCCESS;
} else
{
tileReplaced.readFromNBT(tileTag);
}
}