public unsafe static void GetPositionPacket(ref byte *ptr, byte id, bool srcExtPos, bool extPos, Position pos, Position oldPos, Orientation rot, Orientation oldRot) { Position delta = GetDelta(pos, oldPos, srcExtPos); bool posChanged = delta.X != 0 || delta.Y != 0 || delta.Z != 0; bool oriChanged = rot.RotY != oldRot.RotY || rot.HeadX != oldRot.HeadX; bool absPosUpdate = Math.Abs(delta.X) > 32 || Math.Abs(delta.Y) > 32 || Math.Abs(delta.Z) > 32; if (absPosUpdate) { *ptr = Opcode.EntityTeleport; ptr++; *ptr = id; ptr++; if (extPos) { WriteI32(ref ptr, pos.X); WriteI32(ref ptr, pos.Y); WriteI32(ref ptr, pos.Z); } else { WriteI16(ref ptr, (short)pos.X); WriteI16(ref ptr, (short)pos.Y); WriteI16(ref ptr, (short)pos.Z); } } else if (posChanged) { byte opcode = oriChanged ? Opcode.RelPosAndOrientationUpdate : Opcode.RelPosUpdate; * ptr = opcode; ptr++; * ptr = id; ptr++; *ptr = (byte)(delta.X); ptr++; *ptr = (byte)(delta.Y); ptr++; *ptr = (byte)(delta.Z); ptr++; } else if (oriChanged) { *ptr = Opcode.OrientationUpdate; ptr++; *ptr = id; ptr++; } if (absPosUpdate || oriChanged) { *ptr = rot.RotY; ptr++; *ptr = rot.HeadX; ptr++; } }
public void SetYawPitch(byte yaw, byte pitch) { Orientation rot = Rot; rot.RotY = yaw; rot.HeadX = pitch; Rot = rot; }