mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 12:42:22 -04:00
Add precise /tp, fixes #296
This commit is contained in:
parent
3ba1b796e5
commit
b062fbefa4
@ -105,7 +105,8 @@ namespace MCGalaxy.Commands {
|
||||
}
|
||||
|
||||
if (value < min || value > max) {
|
||||
Player.Message(p, "{0} must be between {1} and {2}", argName, min, max);
|
||||
Player.Message(p, "{0} must be between {1} and {2}", argName,
|
||||
min.ToString("F4"), max.ToString("F4"));
|
||||
return false;
|
||||
}
|
||||
result = value; return true;
|
||||
|
@ -26,14 +26,20 @@ namespace MCGalaxy.Commands.Misc {
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
|
||||
public override bool SuperUseable { get { return false; } }
|
||||
public override CommandAlias[] Aliases {
|
||||
get { return new [] { new CommandAlias("Teleport") }; }
|
||||
get { return new [] { new CommandAlias("Teleport"), new CommandAlias("TPP", "-precise") }; }
|
||||
}
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
string[] args = message.SplitSpaces();
|
||||
if (message.Length == 0 || args.Length > 3) { Help(p); return; }
|
||||
if (message.Length == 0 || args.Length > 4) { Help(p); return; }
|
||||
if (args.Length == 3) { TeleportCoords(p, args); return; }
|
||||
|
||||
if (message.CaselessStarts("-precise ")) {
|
||||
if (args.Length != 4) { Help(p); return; }
|
||||
TeleportCoordsPrecise(p, args);
|
||||
return;
|
||||
}
|
||||
|
||||
Player target = null;
|
||||
PlayerBot bot = null;
|
||||
if (args.Length == 1) {
|
||||
@ -73,6 +79,15 @@ namespace MCGalaxy.Commands.Misc {
|
||||
PlayerActions.MoveCoords(p, P.X, P.Y, P.Z, p.Rot.RotY, p.Rot.HeadX);
|
||||
}
|
||||
|
||||
static void TeleportCoordsPrecise(Player p, string[] args) {
|
||||
Vec3S32 P = new Vec3S32(p.Pos.X, p.Pos.Y + Entities.CharacterHeight, p.Pos.Z);
|
||||
if (!CommandParser.GetCoords(p, args, 1, ref P)) return;
|
||||
|
||||
SavePreTeleportState(p);
|
||||
Position pos = new Position(P.X, P.Y - Entities.CharacterHeight, P.Z);
|
||||
p.SendPos(Entities.SelfID, pos, p.Rot);
|
||||
}
|
||||
|
||||
static void SavePreTeleportState(Player p) {
|
||||
p.PreTeleportMap = p.level.name;
|
||||
p.PreTeleportPos = p.Pos;
|
||||
@ -97,14 +112,15 @@ namespace MCGalaxy.Commands.Misc {
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "%HUse ~ before a coordinate to move relative to current position");
|
||||
Player.Message(p, "%T/TP [x y z]");
|
||||
Player.Message(p, "%HTeleports yourself to the given block coordinates.");
|
||||
Player.Message(p, "%HUse ~ before a coordinate to move relative to current position");
|
||||
Player.Message(p, "%T/TP -precise [x y z]");
|
||||
Player.Message(p, "%HTeleports using precise units. (32 units = 1 block)");
|
||||
Player.Message(p, "%T/TP [player]");
|
||||
Player.Message(p, "%HTeleports yourself to that player.");
|
||||
Player.Message(p, "%T/TP bot [name]");
|
||||
Player.Message(p, "%HTeleports yourself to that bot.");
|
||||
Player.Message(p, "%H Use /p2p to teleport a given player to a different player.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -138,22 +138,14 @@ namespace MCGalaxy {
|
||||
|
||||
static bool CheckFloat(Player p, string raw, string variable,
|
||||
ref int modify, int scale, float min, float max) {
|
||||
float value;
|
||||
float value = 0;
|
||||
min /= scale; max /= scale;
|
||||
if (!CommandParser.GetReal(p, raw, variable, ref value, min, max)) return false;
|
||||
|
||||
if (!Utils.TryParseDecimal(raw, out value)) {
|
||||
Player.Message(p, "Env: \"{0}\" is not a valid decimal.", value);
|
||||
return false;
|
||||
} else if (value < min || value > max) {
|
||||
Player.Message(p, "Env: \"{0}\" must be between {1} and {2}.",
|
||||
value, min.ToString("F4"), max.ToString("F4"));
|
||||
return false;
|
||||
} else {
|
||||
modify = (int)(value * scale);
|
||||
Player.Message(p, "Set {0} for {1} %Sto {2}", variable, p.level.ColoredName, value.ToString("F4"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsResetString(string value) {
|
||||
return value.CaselessEq("normal") ||
|
||||
|
@ -245,6 +245,6 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
public enum EntityProp : byte {
|
||||
RotX = 0, RotY = 1, RotZ = 2,
|
||||
RotX = 0, RotY = 1, RotZ = 2, ScaleX = 3, ScaleY = 4, ScaleZ = 5,
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user