mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
Allow setting yaw and pitch in /tp
This commit is contained in:
parent
350e1619e1
commit
1ec0531bca
@ -30,7 +30,7 @@ namespace MCGalaxy.Blocks.Extended {
|
|||||||
"WHERE EntryX=@0 AND EntryY=@1 AND EntryZ=@2", x, y, z);
|
"WHERE EntryX=@0 AND EntryY=@1 AND EntryZ=@2", x, y, z);
|
||||||
int last = Portals.Rows.Count - 1;
|
int last = Portals.Rows.Count - 1;
|
||||||
if (last == -1) { Portals.Dispose(); return false; }
|
if (last == -1) { Portals.Dispose(); return false; }
|
||||||
byte yaw = p.Rot.RotY, pitch = p.Rot.HeadX;
|
Orientation rot = p.Rot;
|
||||||
|
|
||||||
DataRow row = Portals.Rows[last];
|
DataRow row = Portals.Rows[last];
|
||||||
string map = row["ExitMap"].ToString();
|
string map = row["ExitMap"].ToString();
|
||||||
@ -49,7 +49,9 @@ namespace MCGalaxy.Blocks.Extended {
|
|||||||
x = ushort.Parse(row["ExitX"].ToString());
|
x = ushort.Parse(row["ExitX"].ToString());
|
||||||
y = ushort.Parse(row["ExitY"].ToString());
|
y = ushort.Parse(row["ExitY"].ToString());
|
||||||
z = ushort.Parse(row["ExitZ"].ToString());
|
z = ushort.Parse(row["ExitZ"].ToString());
|
||||||
PlayerActions.MoveCoords(p, x, y, z, yaw, pitch);
|
|
||||||
|
Position pos = Position.FromFeetBlockCoords(x, y, z);
|
||||||
|
p.SendPos(Entities.SelfID, pos, rot);
|
||||||
Portals.Dispose();
|
Portals.Dispose();
|
||||||
return true;
|
return true;
|
||||||
} catch {
|
} catch {
|
||||||
|
@ -45,7 +45,7 @@ namespace MCGalaxy.Commands.World {
|
|||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
Player.Message(p, "%T/DeleteLvl [map]");
|
Player.Message(p, "%T/DeleteLvl [map]");
|
||||||
Player.Message(p, "%HCompletely deletes [map] (portals, MBs, everything");
|
Player.Message(p, "%HCompletely deletes [map] (portals, MBs, everything)");
|
||||||
Player.Message(p, "%HA backup of the map will be placed in the levels/deleted folder");
|
Player.Message(p, "%HA backup of the map will be placed in the levels/deleted folder");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ namespace MCGalaxy.Commands.World {
|
|||||||
Player.Message(p, "You may only perform that action on your own map."); return;
|
Player.Message(p, "You may only perform that action on your own map."); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd == "ADD") {
|
if (IsCreateCommand(cmd)) {
|
||||||
AddMap(p, value);
|
AddMap(p, value);
|
||||||
} else if (cmd == "PHYSICS") {
|
} else if (cmd == "PHYSICS") {
|
||||||
if (value == "0" || value == "1" || value == "2" || value == "3" || value == "4" || value == "5") {
|
if (value == "0" || value == "1" || value == "2" || value == "3" || value == "4" || value == "5") {
|
||||||
|
@ -48,7 +48,7 @@ namespace MCGalaxy.Commands.Misc {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3S32 P = p.Pos.BlockFeetCoords;
|
Vec3S32 P = p.Pos.FeetBlockCoords;
|
||||||
for (int dx = -1; dx <= 1; dx++)
|
for (int dx = -1; dx <= 1; dx++)
|
||||||
for (int dy = -1; dy <= 1; dy++)
|
for (int dy = -1; dy <= 1; dy++)
|
||||||
for (int dz = -1; dz <= 1; dz++)
|
for (int dz = -1; dz <= 1; dz++)
|
||||||
@ -66,7 +66,8 @@ namespace MCGalaxy.Commands.Misc {
|
|||||||
else pitch = 8;
|
else pitch = 8;
|
||||||
|
|
||||||
if (dx != 0 || dy != 0 || dz != 0) {
|
if (dx != 0 || dy != 0 || dz != 0) {
|
||||||
PlayerActions.MoveCoords(p, P.X + dx, P.Y + dy, P.Z + dz, yaw, pitch);
|
Position pos = Position.FromFeetBlockCoords(P.X + dx, P.Y + dy, P.Z + dz);
|
||||||
|
p.SendPos(Entities.SelfID, pos, new Orientation(yaw, pitch));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -28,17 +28,18 @@ namespace MCGalaxy.Commands.Misc {
|
|||||||
get { return new [] { new CommandAlias("Teleport"), new CommandAlias("TPP", "-precise") }; }
|
get { return new [] { new CommandAlias("Teleport"), new CommandAlias("TPP", "-precise") }; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Use(Player p, string message) {
|
const string precisePrefix = "-precise ";
|
||||||
string[] args = message.SplitSpaces();
|
public override void Use(Player p, string message) {
|
||||||
if (message.Length == 0 || args.Length > 4) { Help(p); return; }
|
if (message.Length == 0) { Help(p); return; }
|
||||||
if (args.Length == 3) { TeleportCoords(p, args); return; }
|
|
||||||
|
|
||||||
if (message.CaselessStarts("-precise ")) {
|
bool preciseTP = message.CaselessStarts(precisePrefix);
|
||||||
if (args.Length != 4) { Help(p); return; }
|
if (preciseTP) {
|
||||||
TeleportCoordsPrecise(p, args);
|
message = message.Substring(precisePrefix.Length);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string[] args = message.SplitSpaces();
|
||||||
|
if (args.Length >= 3) { TeleportCoords(p, args, preciseTP); return; }
|
||||||
|
|
||||||
Player target = null;
|
Player target = null;
|
||||||
PlayerBot bot = null;
|
PlayerBot bot = null;
|
||||||
if (args.Length == 1) {
|
if (args.Length == 1) {
|
||||||
@ -70,21 +71,35 @@ namespace MCGalaxy.Commands.Misc {
|
|||||||
p.SendPos(Entities.SelfID, pos, rot);
|
p.SendPos(Entities.SelfID, pos, rot);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TeleportCoords(Player p, string[] args) {
|
static void TeleportCoords(Player p, string[] args, bool precise) {
|
||||||
Vec3S32 P = p.Pos.BlockFeetCoords;
|
Vec3S32 P; Position pos;
|
||||||
if (!CommandParser.GetCoords(p, args, 0, ref P)) return;
|
|
||||||
|
if (!precise) {
|
||||||
|
// relative to feet block coordinates
|
||||||
|
P = p.Pos.FeetBlockCoords;
|
||||||
|
if (!CommandParser.GetCoords(p, args, 0, ref P)) return;
|
||||||
|
pos = Position.FromFeetBlockCoords(P.X, P.Y, P.Z);
|
||||||
|
} else {
|
||||||
|
// relative to feet position exactly
|
||||||
|
P = new Vec3S32(p.Pos.X, p.Pos.Y + Entities.CharacterHeight, p.Pos.Z);
|
||||||
|
if (!CommandParser.GetCoords(p, args, 0, ref P)) return;
|
||||||
|
pos = new Position(P.X, P.Y - Entities.CharacterHeight, P.Z);
|
||||||
|
}
|
||||||
|
|
||||||
|
byte yaw = p.Rot.RotY, pitch = p.Rot.HeadX;
|
||||||
|
int angle = 0;
|
||||||
|
|
||||||
|
if (args.Length > 3) {
|
||||||
|
if (!CommandParser.GetInt(p, args[3], "Yaw angle", ref angle, -360, 360)) return;
|
||||||
|
yaw = Orientation.DegreesToPacked(angle);
|
||||||
|
}
|
||||||
|
if (args.Length > 4) {
|
||||||
|
if (!CommandParser.GetInt(p, args[4], "Pitch angle", ref angle, -360, 360)) return;
|
||||||
|
pitch = Orientation.DegreesToPacked(angle);
|
||||||
|
}
|
||||||
|
|
||||||
SavePreTeleportState(p);
|
SavePreTeleportState(p);
|
||||||
PlayerActions.MoveCoords(p, P.X, P.Y, P.Z, p.Rot.RotY, p.Rot.HeadX);
|
p.SendPos(Entities.SelfID, pos, new Orientation(yaw, pitch));
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
static void SavePreTeleportState(Player p) {
|
||||||
@ -112,9 +127,9 @@ namespace MCGalaxy.Commands.Misc {
|
|||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
Player.Message(p, "%HUse ~ before a coordinate to move relative to current position");
|
Player.Message(p, "%HUse ~ before a coordinate to move relative to current position");
|
||||||
Player.Message(p, "%T/TP [x y z]");
|
Player.Message(p, "%T/TP [x y z] <yaw> <pitch>");
|
||||||
Player.Message(p, "%HTeleports yourself to the given block coordinates.");
|
Player.Message(p, "%HTeleports yourself to the given block coordinates.");
|
||||||
Player.Message(p, "%T/TP -precise [x y z]");
|
Player.Message(p, "%T/TP -precise [x y z] <yaw> <pitch>");
|
||||||
Player.Message(p, "%HTeleports using precise units. (32 units = 1 block)");
|
Player.Message(p, "%HTeleports using precise units. (32 units = 1 block)");
|
||||||
Player.Message(p, "%T/TP [player]");
|
Player.Message(p, "%T/TP [player]");
|
||||||
Player.Message(p, "%HTeleports yourself to that player.");
|
Player.Message(p, "%HTeleports yourself to that player.");
|
||||||
|
@ -38,7 +38,7 @@ namespace MCGalaxy.Core {
|
|||||||
if (!IPThrottler.CheckIP(p)) return false;
|
if (!IPThrottler.CheckIP(p)) return false;
|
||||||
if (!CheckTempban(p)) return false;
|
if (!CheckTempban(p)) return false;
|
||||||
|
|
||||||
bool whitelisted = CheckWhitelist(p.name, p.ip);
|
bool whitelisted = CheckWhitelist(p);
|
||||||
if (!whitelisted) {
|
if (!whitelisted) {
|
||||||
p.Leave(null, "This is a private server!", true);
|
p.Leave(null, "This is a private server!", true);
|
||||||
return false;
|
return false;
|
||||||
@ -95,12 +95,12 @@ namespace MCGalaxy.Core {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool CheckWhitelist(string name, string ip) {
|
static bool CheckWhitelist(Player p) {
|
||||||
if (!ServerConfig.WhitelistedOnly) return true;
|
if (!ServerConfig.WhitelistedOnly) return true;
|
||||||
if (ServerConfig.VerifyNames) return Server.whiteList.Contains(name);
|
if (!Server.whiteList.Contains(p.name)) return false;
|
||||||
|
|
||||||
// Verify names is off, check if the player is on the same IP.
|
// If verify names is off, check if the player is on the same IP.
|
||||||
return Server.whiteList.Contains(name) && PlayerInfo.FindAccounts(ip).Contains(name);
|
return ServerConfig.VerifyNames || PlayerInfo.FindAccounts(p.ip).Contains(p.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool CheckPlayersCount(Player p) {
|
static bool CheckPlayersCount(Player p) {
|
||||||
|
@ -38,12 +38,15 @@ namespace MCGalaxy {
|
|||||||
public Position(int x, int y, int z) { X = x; Y = y; Z = z; }
|
public Position(int x, int y, int z) { X = x; Y = y; Z = z; }
|
||||||
|
|
||||||
public static Position FromFeet(int x, int y, int z) { return new Position(x, y + Entities.CharacterHeight, z); }
|
public static Position FromFeet(int x, int y, int z) { return new Position(x, y + Entities.CharacterHeight, z); }
|
||||||
|
public static Position FromFeetBlockCoords(int bX, int bY, int bZ) {
|
||||||
|
return Position.FromFeet(16 + bX * 32, bY * 32, 16 + bZ * 32);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary> World/block coordinate of this position. </summary>
|
/// <summary> World/block coordinate of this position. </summary>
|
||||||
public Vec3S32 BlockCoords { get { return new Vec3S32(X >> 5, Y >> 5, Z >> 5); } }
|
public Vec3S32 BlockCoords { get { return new Vec3S32(X >> 5, Y >> 5, Z >> 5); } }
|
||||||
|
|
||||||
/// <summary> World/block coordinate of this position. </summary>
|
/// <summary> World/block coordinate of this position. </summary>
|
||||||
public Vec3S32 BlockFeetCoords { get { return new Vec3S32(X >> 5, (Y - Entities.CharacterHeight) >> 5, Z >> 5); } }
|
public Vec3S32 FeetBlockCoords { get { return new Vec3S32(X >> 5, (Y - Entities.CharacterHeight) >> 5, Z >> 5); } }
|
||||||
|
|
||||||
/// <summary> X block coordinate of this position. </summary>
|
/// <summary> X block coordinate of this position. </summary>
|
||||||
public int BlockX { get { return X >> 5; } }
|
public int BlockX { get { return X >> 5; } }
|
||||||
|
@ -244,12 +244,11 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void OnListChanged(Player p, Level lvl, string name, bool whitelist, bool removedFromOpposite) {
|
public override void OnListChanged(Player p, Level lvl, string name, bool whitelist, bool removedFromOpposite) {
|
||||||
string type = IsVisit ? "visit" : "build";
|
|
||||||
string msg = PlayerInfo.GetColoredName(p, name);
|
string msg = PlayerInfo.GetColoredName(p, name);
|
||||||
if (removedFromOpposite) {
|
if (removedFromOpposite) {
|
||||||
msg += " %Swas removed from the " + type + (whitelist ? " blacklist" : " whitelist");
|
msg += " %Swas removed from the " + Type + (whitelist ? " blacklist" : " whitelist");
|
||||||
} else {
|
} else {
|
||||||
msg += " %Swas " + type + (whitelist ? " whitelisted" : " blacklisted");
|
msg += " %Swas " + Type + (whitelist ? " whitelisted" : " blacklisted");
|
||||||
}
|
}
|
||||||
DoChange(p, lvl, msg);
|
DoChange(p, lvl, msg);
|
||||||
}
|
}
|
||||||
|
@ -24,12 +24,6 @@ using MCGalaxy.Commands.World;
|
|||||||
namespace MCGalaxy {
|
namespace MCGalaxy {
|
||||||
public static class PlayerActions {
|
public static class PlayerActions {
|
||||||
|
|
||||||
/// <summary> Moves the player to the specified block coordinates. (bY is treated as player feet) </summary>
|
|
||||||
public static void MoveCoords(Player p, int bX, int bY, int bZ, byte rotX, byte rotY) {
|
|
||||||
Position pos = Position.FromFeet(16 + bX * 32, bY * 32, 16 + bZ * 32);
|
|
||||||
p.SendPos(Entities.SelfID, pos, new Orientation(rotX, rotY));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> Moves the player to the specified map. </summary>
|
/// <summary> Moves the player to the specified map. </summary>
|
||||||
public static bool ChangeMap(Player p, string name) { return ChangeMap(p, null, name); }
|
public static bool ChangeMap(Player p, string name) { return ChangeMap(p, null, name); }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user