Example #1
0
        public static void HandlePacketPlayerPositionRotation(TestClient client, PlayerPositionRotationPacket ppr)
        {
            client.Position = new AbsWorldCoords(ppr.X, ppr.Y, ppr.Z);

            client.SendPacket(ppr);
            client.WaitInitialPositionRequest = false;
        }
Example #2
0
        public static void HandlePacketPlayerPositionRotation(Client client, PlayerPositionRotationPacket packet)
        {
            double feetY = packet.Y - client.Owner.EyeHeight;

            if (client.WaitForInitialPosAck)
            {
                AbsWorldCoords coords = new AbsWorldCoords(packet.X, feetY, packet.Z);
                if (coords == client.Owner.LoginPosition)
                {
                    client.WaitForInitialPosAck = false;
                    client.SendSecondLoginSequence();
                }
            }
            else
            {
                double threshold = 0.001;
                double diffX     = Math.Abs(client.Owner.Position.X - packet.X);
                double diffY     = Math.Abs(client.Owner.Position.Y - feetY);
                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, feetY, packet.Z), packet.Yaw, packet.Pitch);
                client.OnGround = packet.OnGround;
                client.Stance   = packet.Stance;

                client.CheckAndUpdateChunks(packet.X, packet.Z);
            }
        }
Example #3
0
        public static void ReadPlayerPositionRotation(Client client, PacketReader reader)
        {
            PlayerPositionRotationPacket ppr = new PlayerPositionRotationPacket();

            ppr.Read(reader);

            if (!reader.Failed)
            {
                Client.HandlePacketPlayerPositionRotation(client, ppr);
            }
        }