Fix syncing issues, properly this time. Should be much cheaper for packets now.

This commit is contained in:
Christian 2013-02-16 22:28:53 -05:00
parent 835729081f
commit efc2184d5a
2 changed files with 6 additions and 3 deletions

View File

@ -32,7 +32,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
@Mod(modid = "IronChest", name = "Iron Chests", dependencies = "required-after:Forge@[6.5,);required-after:FML@[4.7.22,)")
@NetworkMod(channels = { "IronChest" }, versionBounds = "[5.0,)", clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
@NetworkMod(channels = { "IronChest" }, versionBounds = "[5.1,)", clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
public class IronChest {
public static BlockIronChest ironChestBlock;
@SidedProxy(clientSide = "cpw.mods.ironchest.client.ClientProxy", serverSide = "cpw.mods.ironchest.CommonProxy")

View File

@ -34,7 +34,9 @@ public class PacketHandler implements IPacketHandler {
int x = dat.readInt();
int y = dat.readInt();
int z = dat.readInt();
byte typ = dat.readByte();
int typDat = dat.readByte();
byte typ = (byte)(typDat & 0xf);
byte facing = (byte)((typDat >> 4) & 0xf);
boolean hasStacks = dat.readByte() != 0;
int[] items = new int[0];
if (hasStacks)
@ -50,6 +52,7 @@ public class PacketHandler implements IPacketHandler {
if (te instanceof TileEntityIronChest)
{
TileEntityIronChest icte = (TileEntityIronChest) te;
icte.setFacing(facing);
icte.handlePacketData(typ, items);
}
}
@ -61,7 +64,7 @@ public class PacketHandler implements IPacketHandler {
int x = tileEntityIronChest.xCoord;
int y = tileEntityIronChest.yCoord;
int z = tileEntityIronChest.zCoord;
int typ = tileEntityIronChest.getType().ordinal();
int typ = (tileEntityIronChest.getType().ordinal() | (tileEntityIronChest.getFacing() << 4)) & 0xFF;
int[] items = tileEntityIronChest.buildIntDataList();
boolean hasStacks = (items != null);
try