internal void UpdatePosition() { bool forceTp = false; if ((DateTime.Now - lastPosSync).TotalSeconds >= 60) { lastPosSync = DateTime.Now; forceTp = true; } Point3 temppos = (pos * 32) / new Point3(32), tempoldpos = (oldpos * 32) / new Point3(32); Point3 diff = temppos - tempoldpos; double diff1 = temppos.mdiff(tempoldpos); //TODO move this? if (isPlayer && p.isFlying) { p.FlyCode(); } if ((int)(diff1 * 32) == 0 && !forceTp) { if ((int)(rot[0] - oldrot[0]) != 0 || (int)(rot[1] - oldrot[1]) != 0) { byte[] bytes = new byte[6]; util.EndianBitConverter.Big.GetBytes(id).CopyTo(bytes, 0); bytes[4] = (byte)(rot[0] / 1.40625); bytes[5] = (byte)(rot[1] / 1.40625); Player.players.ForEach(delegate(Player pl) { if (pl != p && pl.MapLoaded && pl.VisibleEntities.Contains(id)) { pl.SendRaw(0x20, bytes); } }); rot.CopyTo(oldrot, 0); } } else if ((int)(diff1 * 32) <= 127 && !forceTp) { Point3 sendme = diff * 32; byte[] bytes = new byte[9]; util.EndianBitConverter.Big.GetBytes(id).CopyTo(bytes, 0); bytes[4] = (byte)sendme.x; bytes[5] = (byte)sendme.y; bytes[6] = (byte)sendme.z; bytes[7] = (byte)(rot[0] / 1.40625); bytes[8] = (byte)(rot[1] / 1.40625); Player.players.ForEach(delegate(Player pl) { if (pl != p && pl.MapLoaded && pl.VisibleEntities.Contains(id)) { pl.SendRaw(0x21, bytes); } }); if (Math.Abs(sendme.x) > 0) { oldpos.x = pos.x; } if (Math.Abs(sendme.y) > 0) { oldpos.y = pos.y; } if (Math.Abs(sendme.z) > 0) { oldpos.z = pos.z; } rot.CopyTo(oldrot, 0); } else { Point3 sendme = pos * 32; byte[] bytes = new byte[18]; util.EndianBitConverter.Big.GetBytes(id).CopyTo(bytes, 0); util.EndianBitConverter.Big.GetBytes((int)sendme.x).CopyTo(bytes, 4); util.EndianBitConverter.Big.GetBytes((int)sendme.y).CopyTo(bytes, 8); util.EndianBitConverter.Big.GetBytes((int)sendme.z).CopyTo(bytes, 12); bytes[16] = (byte)(rot[0] / 1.40625); bytes[17] = (byte)(rot[1] / 1.40625); Player.players.ForEach(delegate(Player pl) { if (pl != p && pl.MapLoaded && pl.VisibleEntities.Contains(id)) { pl.SendRaw(0x22, bytes); } }); oldpos = pos; rot.CopyTo(oldrot, 0); } }