Beispiel #1
0
        public static void HandlePacketPlayerPosition(Client client, PlayerPositionPacket packet)
        {
            if (client.WaitForInitialPosAck)
            {
                return;
            }

            //client.Logger.Log(Chraft.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);
        }
Beispiel #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);
            }
        }
Beispiel #3
0
        public static void HandlePacketPlayerPositionRotation(Client client, PlayerPositionRotationPacket packet)
        {
            //client.Logger.Log(Chraft.Logger.LogLevel.Info, "Player position: {0} {1} {2}", packet.X, packet.Y, packet.Z);
            client.Owner.MoveTo(packet.X, packet.Y - Player.EyeGroundOffset, packet.Z, packet.Yaw, packet.Pitch);
            client.OnGround = packet.OnGround;
            client.Stance = packet.Stance;

            client.CheckAndUpdateChunks(packet.X, packet.Z);
        }
Beispiel #4
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);
            }
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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(new AbsWorldCoords(packet.X, packet.Y, packet.Z));
            client.OnGround = packet.OnGround;
            client.Stance = packet.Stance;

            client.CheckAndUpdateChunks(packet.X, packet.Z);
        }