static void SpawnRaw(Player dst, byte id, Entity entity, Position pos, Orientation rot, string skin, string name, string model) { // NOTE: Fix for standard clients if (id == Entities.SelfID) { pos.Y -= 22; } name = Colors.Cleanup(name, dst.hasTextColors); if (dst.Supports(CpeExt.ExtPlayerList, 2)) { dst.Send(Packet.ExtAddEntity2(id, skin, name, pos, rot, dst.hasCP437, dst.hasExtPositions)); } else if (dst.hasExtList) { dst.Send(Packet.ExtAddEntity(id, skin, name, dst.hasCP437)); dst.Send(Packet.Teleport(id, pos, rot, dst.hasExtPositions)); } else { dst.Send(Packet.AddEntity(id, name, pos, rot, dst.hasCP437, dst.hasExtPositions)); } if (dst.hasChangeModel && !model.CaselessEq("humanoid")) { SendModel(dst, id, model); } if (dst.Supports(CpeExt.EntityProperty)) { dst.Send(Packet.EntityProperty(id, EntityProp.RotX, Orientation.PackedToDegrees(rot.RotX))); dst.Send(Packet.EntityProperty(id, EntityProp.RotZ, Orientation.PackedToDegrees(rot.RotZ))); SendModelScales(dst, id, entity); } }
void CheckDirection(SchedulerTask task) { Player[] players = PlayerInfo.Online.Items; foreach (Player p in players) { if (Orientation.PackedToDegrees(p.Rot.RotY) >= 0 && Orientation.PackedToDegrees(p.Rot.RotY) < 45) { p.SendCpeMessage(CpeMessageType.Status1, "%SFacing:"); p.SendCpeMessage(CpeMessageType.Status2, "%bNorth"); } if (Orientation.PackedToDegrees(p.Rot.RotY) >= 45 && Orientation.PackedToDegrees(p.Rot.RotY) < 90) { p.SendCpeMessage(CpeMessageType.Status1, "%SFacing:"); p.SendCpeMessage(CpeMessageType.Status2, "%bNortheast"); } if (Orientation.PackedToDegrees(p.Rot.RotY) >= 90 && Orientation.PackedToDegrees(p.Rot.RotY) < 135) { p.SendCpeMessage(CpeMessageType.Status1, "%SFacing:"); p.SendCpeMessage(CpeMessageType.Status2, "%bEast"); } if (Orientation.PackedToDegrees(p.Rot.RotY) >= 135 && Orientation.PackedToDegrees(p.Rot.RotY) < 180) { p.SendCpeMessage(CpeMessageType.Status1, "%SFacing:"); p.SendCpeMessage(CpeMessageType.Status2, "%bSoutheast"); } if (Orientation.PackedToDegrees(p.Rot.RotY) >= 180 && Orientation.PackedToDegrees(p.Rot.RotY) < 225) { p.SendCpeMessage(CpeMessageType.Status1, "%SFacing:"); p.SendCpeMessage(CpeMessageType.Status2, "%bSouth"); } if (Orientation.PackedToDegrees(p.Rot.RotY) >= 225 && Orientation.PackedToDegrees(p.Rot.RotY) < 270) { p.SendCpeMessage(CpeMessageType.Status1, "%SFacing:"); p.SendCpeMessage(CpeMessageType.Status2, "%bSouthwest"); } if (Orientation.PackedToDegrees(p.Rot.RotY) >= 270 && Orientation.PackedToDegrees(p.Rot.RotY) < 315) { p.SendCpeMessage(CpeMessageType.Status1, "%SFacing:"); p.SendCpeMessage(CpeMessageType.Status2, "%bWest"); } if (Orientation.PackedToDegrees(p.Rot.RotY) >= 315 && Orientation.PackedToDegrees(p.Rot.RotY) < 361) { p.SendCpeMessage(CpeMessageType.Status1, "%SFacing:"); p.SendCpeMessage(CpeMessageType.Status2, "%bNorthwest"); } } }
public static void UpdateEntityProp(Entity entity, EntityProp prop, int value) { Player[] players = PlayerInfo.Online.Items; Level lvl = entity.Level; Orientation rot = entity.Rot; byte angle = Orientation.DegreesToPacked(value); if (prop == EntityProp.RotX) { rot.RotX = angle; } if (prop == EntityProp.RotY) { rot.RotY = angle; } if (prop == EntityProp.RotZ) { rot.RotZ = angle; } entity.Rot = rot; if (prop == EntityProp.RotY) { entity.SetYawPitch(rot.RotY, rot.HeadX); } foreach (Player pl in players) { if (pl.level != lvl || !pl.Supports(CpeExt.EntityProperty)) { continue; } if (!pl.CanSeeEntity(entity)) { continue; } byte id = (pl == entity) ? Entities.SelfID : entity.EntityID; pl.Send(Packet.EntityProperty(id, prop, Orientation.PackedToDegrees(angle))); } }
static void SpawnRaw(Player dst, byte id, Entity e, Position pos, Orientation rot, string skin, string name, string model) { dst.Session.SendSpawnEntity(id, name, skin, pos, rot); if (dst.hasChangeModel) { OnSendingModelEvent.Call(e, ref model, dst); if (!model.CaselessEq("humanoid")) { dst.Session.SendChangeModel(id, model); } } if (dst.Supports(CpeExt.EntityProperty)) { dst.Send(Packet.EntityProperty(id, EntityProp.RotX, Orientation.PackedToDegrees(rot.RotX))); dst.Send(Packet.EntityProperty(id, EntityProp.RotZ, Orientation.PackedToDegrees(rot.RotZ))); SendModelScales(dst, id, e); } }
/// <summary> /// Calculates cardinal direction based on bot's yaw value. /// </summary> /// <param name="bot"></param> /// <returns></returns> public static string CalculateCardinal(PlayerBot bot) { if (Orientation.PackedToDegrees(bot.Rot.RotY) >= 0 && Orientation.PackedToDegrees(bot.Rot.RotY) < 45) { return("North"); } if (Orientation.PackedToDegrees(bot.Rot.RotY) >= 45 && Orientation.PackedToDegrees(bot.Rot.RotY) < 90) { return("Northeast"); } if (Orientation.PackedToDegrees(bot.Rot.RotY) >= 90 && Orientation.PackedToDegrees(bot.Rot.RotY) < 135) { return("East"); } if (Orientation.PackedToDegrees(bot.Rot.RotY) >= 135 && Orientation.PackedToDegrees(bot.Rot.RotY) < 180) { return("Southeast"); } if (Orientation.PackedToDegrees(bot.Rot.RotY) >= 180 && Orientation.PackedToDegrees(bot.Rot.RotY) < 225) { return("South"); } if (Orientation.PackedToDegrees(bot.Rot.RotY) >= 225 && Orientation.PackedToDegrees(bot.Rot.RotY) < 270) { return("Southwest"); } if (Orientation.PackedToDegrees(bot.Rot.RotY) >= 270 && Orientation.PackedToDegrees(bot.Rot.RotY) < 315) { return("West"); } if (Orientation.PackedToDegrees(bot.Rot.RotY) >= 315 && Orientation.PackedToDegrees(bot.Rot.RotY) < 361) { return("Northwest"); } return(""); }