|
4 | 4 | import net.minecraft.entity.Entity; |
5 | 5 | import net.minecraft.nbt.NBTTagCompound; |
6 | 6 | import net.minecraft.nbt.NBTTagList; |
| 7 | +import net.minecraft.network.play.server.SPacketUpdateTileEntity; |
7 | 8 | import net.minecraft.tileentity.TileEntity; |
8 | 9 | import net.minecraft.util.ResourceLocation; |
9 | | -import net.minecraft.util.math.BlockPos; |
10 | 10 | import net.minecraft.world.IBlockAccess; |
11 | 11 | import net.minecraft.world.NextTickListEntry; |
12 | 12 | import net.minecraft.world.World; |
@@ -42,6 +42,7 @@ public static NBTTagCompound writeChunkToNBT(Chunk chunkIn, World worldIn, NBTTa |
42 | 42 | NBTTagList nbttaglist = new NBTTagList(); |
43 | 43 | boolean flag = worldIn.provider.hasSkyLight(); |
44 | 44 |
|
| 45 | + |
45 | 46 | for (ExtendedBlockStorage extendedblockstorage : aextendedblockstorage) |
46 | 47 | { |
47 | 48 | if (extendedblockstorage != Chunk.NULL_BLOCK_STORAGE) |
@@ -115,6 +116,12 @@ public static NBTTagCompound writeChunkToNBT(Chunk chunkIn, World worldIn, NBTTa |
115 | 116 | nbttagcompound3.setTag(tagName, extraData); |
116 | 117 | } |
117 | 118 |
|
| 119 | + SPacketUpdateTileEntity updatePacket = tileentity.getUpdatePacket(); |
| 120 | + if(updatePacket != null && updatePacket.getNbtCompound() != null) { |
| 121 | + NBTTagCompound updateData = updatePacket.getNbtCompound(); |
| 122 | + nbttagcompound3.setTag("cm3_update", updateData); |
| 123 | + } |
| 124 | + |
118 | 125 | nbttaglist2.appendTag(nbttagcompound3); |
119 | 126 | } |
120 | 127 | catch (Exception e) |
@@ -233,6 +240,16 @@ public static void loadEntities(World worldIn, NBTTagCompound compound, Chunk ch |
233 | 240 | } |
234 | 241 |
|
235 | 242 | chunk.addTileEntity(tileentity); |
| 243 | + |
| 244 | + if(nbttagcompound2.hasKey("cm3_update")) { |
| 245 | + NBTTagCompound tag = nbttagcompound2.getCompoundTag("cm3_update"); |
| 246 | + |
| 247 | + try { |
| 248 | + tileentity.onDataPacket(null, new SPacketUpdateTileEntity(tileentity.getPos(), 1, tag)); |
| 249 | + } catch (NullPointerException npe) { |
| 250 | + Logz.debug("TileEntity '%s' is unable to read data packet without a network manager instance.", tileentity.getClass().getName()); |
| 251 | + } |
| 252 | + } |
236 | 253 | } |
237 | 254 | } |
238 | 255 | } |
|
0 commit comments