private void OnPlayerPosition(PlayerPositionPacket p) { if (PlayerPosition != null) PlayerPosition.Invoke(this, new PacketEventArgs<PlayerPositionPacket>(p)); }
public static void ReadPlayerPosition(Client client, PacketReader reader) { PlayerPositionPacket pp = new PlayerPositionPacket(); pp.Read(reader); if (!reader.Failed) Client.HandlePacketPlayerPosition(client, pp); }
public static void HandlePacketPlayerPosition(Client client, PlayerPositionPacket packet) { //client.Logger.Log(Chraft.Logger.LogLevel.Info, "Player position: {0} {1} {2}", packet.X, packet.Y, packet.Z); client.Owner.Ready = true; client.Owner.MoveTo(packet.X, packet.Y, packet.Z); client.OnGround = packet.OnGround; client.Stance = packet.Stance; client.CheckAndUpdateChunks(packet.X, packet.Z); }
public static void HandlePacketPlayerPosition(Client client, PlayerPositionPacket packet) { if(client.WaitForInitialPosAck) return; //client.Logger.Log(Chraft.Logger.LogLevel.Info, "Player position: {0} {1} {2}", packet.X, packet.Y, packet.Z); client.Owner.Ready = true; double threshold = 0.001; double diffX = Math.Abs(client.Owner.Position.X - packet.X); double diffY = Math.Abs(client.Owner.Position.Y - packet.Y); double diffZ = Math.Abs(client.Owner.Position.Z - packet.Z); if (diffX < threshold && diffY < threshold && diffZ < threshold) return; client.Owner.MoveTo(new AbsWorldCoords(packet.X, packet.Y, packet.Z)); client.OnGround = packet.OnGround; client.Stance = packet.Stance; client.CheckAndUpdateChunks(packet.X, packet.Z); }