diff --git a/StevenDimDoors/mod_pocketDim/SchematicLoader.java b/StevenDimDoors/mod_pocketDim/SchematicLoader.java index 91eedad8..9371e384 100644 --- a/StevenDimDoors/mod_pocketDim/SchematicLoader.java +++ b/StevenDimDoors/mod_pocketDim/SchematicLoader.java @@ -17,6 +17,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.tileentity.TileEntityDispenser; import net.minecraft.util.WeightedRandomChestContent; @@ -39,10 +40,12 @@ public class SchematicLoader public byte[] blockId =new byte[0]; public byte[] addId = new byte[0]; + + public NBTTagCompound[] tileEntityList; public NBTTagList entities; - public NBTTagList tileentities; + public NBTTagList tileEntities; private Random rand = new Random(); @@ -103,6 +106,15 @@ public class SchematicLoader addId = nbtdata.getByteArray("AddBlocks"); + tileEntities = nbtdata.getTagList("TileEntities"); + tileEntityList = new NBTTagCompound[width*height*length]; + + for(int count = 0; count tileEntities = new ArrayList(); - byte[] blocks = new byte[width * height * length]; + + NBTTagList tileEntites = new NBTTagList(); + byte[] blocks = new byte[width * height * length]; byte[] addBlocks = null; byte[] blockData = new byte[width * height * length]; for (int x = 0; x < width; ++x) { - for (int y = 0; y < height; ++y) { - for (int z = 0; z < length; ++z) { + for (int y = 0; y < height; ++y) + { + for (int z = 0; z < length; ++z) + { int index = y * width * length + z * width + x; int blockID = world.getBlockId(x+xMin, y+yMin, z+zMin); int meta= world.getBlockMetadata(x+xMin, y+yMin, z+zMin); @@ -388,8 +402,10 @@ public class DungeonHelper } // Save 4096 IDs in an AddBlocks section - if (blockID > 255) { - if (addBlocks == null) { // Lazily create section + if (blockID > 255) + { + if (addBlocks == null) + { // Lazily create section addBlocks = new byte[(blocks.length >> 1) + 1]; } @@ -400,6 +416,23 @@ public class DungeonHelper blocks[index] = (byte) blockID; blockData[index] = (byte) meta; + + if (Block.blocksList[blockID] instanceof BlockContainer) + { + TileEntity tileEntityBlock = world.getBlockTileEntity(x+xMin, y+yMin, z+zMin); + NBTTagCompound tag = new NBTTagCompound(); + tileEntityBlock.writeToNBT(tag); + + + // Get the list of key/values from the block + + if (tag != null) + { + tileEntites.appendTag(tag); + } + } + + } } } @@ -420,6 +453,7 @@ public class DungeonHelper schematic.put("Width", new ShortTag("Width", (short) width)); schematic.put("Length", new ShortTag("Length", (short) length)); schematic.put("Height", new ShortTag("Height", (short) height)); + schematic.put("TileEntites", tileEntites); if (addBlocks != null) { schematic.put("AddBlocks", new ByteArrayTag("AddBlocks", addBlocks)); }