-Add: sync serverPos[XYZ] on spawning of entity

This fixes the issue that, up to 400 ticks from getting in range,
entities have a wrong offset (because server and client don't agree on
the position to calculate relative updates from)
This commit is contained in:
TrueBrain committed 2012-07-09 14:00:47 +02:00
1 parent 1012531538
commit 7dff7fd62d
5 files changed
+95 -1

No files matched your search

@@ -51,6 +51,12 @@ public class PacketHandlerClient extends PacketHandlerBase
pkt.readData(data);
onOpenGui((PacketOpenGUI)pkt);
break;
case ForgePacket.TRACK:
pkt = new PacketEntityTrack();
pkt.readData(data);
onEntityTrackPacket((PacketEntityTrack)pkt, ModLoader.getMinecraftInstance().theWorld);
break;
}
}
catch (IOException e)
@@ -60,6 +66,27 @@ public class PacketHandlerClient extends PacketHandlerBase
}
}
/**
* Process the Entity Track packet. This corrects the serverPos[XYZ] to match
* with the server, so any following relative updates are valid.
* @param packet The Track Packet
* @param world The world the entity is in
*/
public void onEntityTrackPacket(PacketEntityTrack packet, World world)
{
if (DEBUG)
{
System.out.println("S->C: " + packet.toString(true));
}
Minecraft mc = ModLoader.getMinecraftInstance();
Entity entity = ((WorldClient)world).getEntityByID(packet.entityId);
entity.serverPosX = packet.serverPosX;
entity.serverPosY = packet.serverPosY;
entity.serverPosZ = packet.serverPosZ;
}
/**
* Processes the Entity Spawn packet. And spawns an entity in world as needed.
* If the client has the required client mod.