From 197f37dc3ac2420fb9e0dbf66072fd8a55b2e9cf Mon Sep 17 00:00:00 2001 From: Goodlyay Date: Mon, 29 Apr 2024 12:13:23 -0700 Subject: [PATCH] Allow /where bot to see bot positions, improve /where output format --- MCGalaxy/Commands/Information/CmdWhere.cs | 36 +++++++++++++---------- MCGalaxy/Entity/Entity.cs | 13 ++++++++ 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/MCGalaxy/Commands/Information/CmdWhere.cs b/MCGalaxy/Commands/Information/CmdWhere.cs index 29f1495de..211fd8ea7 100644 --- a/MCGalaxy/Commands/Information/CmdWhere.cs +++ b/MCGalaxy/Commands/Information/CmdWhere.cs @@ -26,27 +26,31 @@ public sealed class CmdWhere : Command2 public override string type { get { return CommandTypes.Information; } } public override void Use(Player p, string message, CommandData data) { - if (message.Length == 0) message = p.name; - Player target = PlayerInfo.FindMatches(p, message); - if (target == null) return; - - if (IGame.GameOn(target.level) != null && !(p.IsSuper || p.Game.Referee)) { - p.Message("You can only use /where on people in games when you are in referee mode."); return; + Entity target; + string targetName; + if (message.CaselessStarts("bot ")) { + string botName = message.SplitSpaces(2)[1]; + target = Matcher.FindBots(p, botName); + if (target == null) return; + targetName = "Bot " + ((PlayerBot)target).DisplayName; + } else { + if (message.Length == 0) message = p.name; + target = PlayerInfo.FindMatches(p, message); + if (target == null) return; + if (IGame.GameOn(target.Level) != null && !(p.IsSuper || p.Game.Referee)) { + p.Message("You can only use /where on people in games when you are in referee mode."); return; + } + targetName = p.FormatNick((Player)target); } - - int x = target.Pos.X, y = target.Pos.Y - Entities.CharacterHeight, z = target.Pos.Z; - p.Message("{0} &Sis on {1}", p.FormatNick(target), target.level.ColoredName); - p.Message(" X: &b{0:F5} &SY: &b{1:F5} &SZ: &b{2:F5}", - x / 32.0, y / 32.0, z / 32.0); - - p.Message(" Yaw: &b{0} &Sdegrees, Pitch: &b{1} &Sdegrees", - Orientation.PackedToDegrees(target.Rot.RotY), - Orientation.PackedToDegrees(target.Rot.HeadX)); - } + + target.DisplayPosition(p, p.FormatNick(targetName)); + } public override void Help(Player p) { p.Message("&T/Where [name]"); p.Message("&HDisplays level, position, and orientation of that player."); + p.Message("&T/Where bot [name]"); + p.Message("&HDisplays level, position, and orientation of that bot."); } } } diff --git a/MCGalaxy/Entity/Entity.cs b/MCGalaxy/Entity/Entity.cs index 12f59b2a2..6feb5ded6 100644 --- a/MCGalaxy/Entity/Entity.cs +++ b/MCGalaxy/Entity/Entity.cs @@ -81,5 +81,18 @@ public void UpdateModel(string model) { SetModel(model); Entities.BroadcastModel(this, model); } + public void DisplayPosition(Player p, string displayName) { + Vec3S32 feet = Pos.FeetBlockCoords; + int x = Pos.X, y = Pos.Y - Entities.CharacterHeight, z = Pos.Z; + p.Message("{0} &Sis on {1}", displayName, Level.ColoredName); + p.Message(" Block coords: &b{0} {1} {2}", + feet.X, feet.Y, feet.Z); + p.Message(" Precise coords: &b{0} {1} {2}", + x, y, z); + + p.Message("Yaw pitch degrees: &b{0} {1}", + Orientation.PackedToDegrees(Rot.RotY), + Orientation.PackedToDegrees(Rot.HeadX)); + } } }