From 84ee22b859f5eedb6cddb60f94665b28d3783b55 Mon Sep 17 00:00:00 2001 From: Modmuss50 Date: Mon, 13 Apr 2015 21:02:30 +0100 Subject: [PATCH] Fixed a few crashes, will finish fixing them tomorrow. --- .../java/techreborn/tiles/TileCentrifuge.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/java/techreborn/tiles/TileCentrifuge.java b/src/main/java/techreborn/tiles/TileCentrifuge.java index 6d0b23ff7..29124a8ce 100644 --- a/src/main/java/techreborn/tiles/TileCentrifuge.java +++ b/src/main/java/techreborn/tiles/TileCentrifuge.java @@ -10,6 +10,7 @@ import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import techreborn.api.CentrifugeRecipie; import techreborn.api.TechRebornAPI; +import techreborn.packets.PacketHandler; import techreborn.util.Inventory; import techreborn.util.ItemUtils; @@ -180,6 +181,10 @@ public class TileCentrifuge extends TileMachineBase implements IInventory { public void writeToNBT(NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); inventory.writeToNBT(tagCompound); + writeUpdateToNBT(tagCompound); + } + + public void writeUpdateToNBT(NBTTagCompound tagCompound) { if(currentRecipe != null){ tagCompound.setString("recipe", currentRecipe.getInputItem().getUnlocalizedName()); } else { @@ -238,6 +243,7 @@ public class TileCentrifuge extends TileMachineBase implements IInventory { @Override public void openInventory() { + syncAllWithAll(); inventory.openInventory(); } @@ -267,6 +273,24 @@ public class TileCentrifuge extends TileMachineBase implements IInventory { return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag); } + public Packet getDescriptionPacketWithOutInv() { + NBTTagCompound nbtTag = new NBTTagCompound(); + writeUpdateToNBT(nbtTag); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag); + } + + public void syncWithAll() { + if (!worldObj.isRemote) { + PacketHandler.sendPacketToAllPlayers(getDescriptionPacketWithOutInv(), worldObj); + } + } + + public void syncAllWithAll() { + if (!worldObj.isRemote) { + PacketHandler.sendPacketToAllPlayers(getDescriptionPacket(), worldObj); + } + } + @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord);