SwapByteOrder() public static method

public static SwapByteOrder ( double val ) : double
val double
return double
Ejemplo n.º 1
0
        private void tmrSpin_Tick(object sender, EventArgs e)
        {
            float movement = 11;

            rotation = (rotation + movement) % 360f;

            if (rotation % 2 == 0)
            {
                PacketHandler h = SMPInterface.Handler;
                h.SetOperationCode(SMPInterface.PacketTypes.PlayerPosition);

                double x = SMPInterface.PlayerX;
                double y = 126.0;
                double z = SMPInterface.PlayerZ;

                x += Math.Cos((rotation / 1.0) * Math.PI * 2.0) * 10.0;
                z += Math.Sin((rotation / 1.0) * Math.PI * 2.0) * 10.0;

                h.Write(SMPInterface.SwapByteOrder(x));
                h.Write(SMPInterface.SwapByteOrder(y));
                h.Write(SMPInterface.SwapByteOrder(y + 0.5));
                h.Write(SMPInterface.SwapByteOrder(z));
                h.Write(false);
                h.Flush();
            }
            else
            {
                float         x = rotation;
                float         y = 0f; // horizontal?
                PacketHandler h = SMPInterface.Handler;
                h.SetOperationCode(SMPInterface.PacketTypes.PlayerLook);
                h.Write(SMPInterface.SwapByteOrder(x));
                h.Write(SMPInterface.SwapByteOrder(y));
                h.Write(false);
                h.Flush();
            }
        }