Skip to content

Commit 14714cb

Browse files
committed
Further improve preview rendering
Incorporate UpdatePacket data into the tile entity data to improve rendering. This should fix e.g. Refined Storage rendering issues.
1 parent 0e9e318 commit 14714cb

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/main/java/org/dave/compactmachines3/utility/ChunkUtils.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import net.minecraft.entity.Entity;
55
import net.minecraft.nbt.NBTTagCompound;
66
import net.minecraft.nbt.NBTTagList;
7+
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
78
import net.minecraft.tileentity.TileEntity;
89
import net.minecraft.util.ResourceLocation;
9-
import net.minecraft.util.math.BlockPos;
1010
import net.minecraft.world.IBlockAccess;
1111
import net.minecraft.world.NextTickListEntry;
1212
import net.minecraft.world.World;
@@ -42,6 +42,7 @@ public static NBTTagCompound writeChunkToNBT(Chunk chunkIn, World worldIn, NBTTa
4242
NBTTagList nbttaglist = new NBTTagList();
4343
boolean flag = worldIn.provider.hasSkyLight();
4444

45+
4546
for (ExtendedBlockStorage extendedblockstorage : aextendedblockstorage)
4647
{
4748
if (extendedblockstorage != Chunk.NULL_BLOCK_STORAGE)
@@ -115,6 +116,12 @@ public static NBTTagCompound writeChunkToNBT(Chunk chunkIn, World worldIn, NBTTa
115116
nbttagcompound3.setTag(tagName, extraData);
116117
}
117118

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+
118125
nbttaglist2.appendTag(nbttagcompound3);
119126
}
120127
catch (Exception e)
@@ -233,6 +240,16 @@ public static void loadEntities(World worldIn, NBTTagCompound compound, Chunk ch
233240
}
234241

235242
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+
}
236253
}
237254
}
238255
}

0 commit comments

Comments
 (0)