mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-25 14:17:29 -04:00
Fix /mark for sure this time with negative coordinates.
This commit is contained in:
parent
aec6cae69e
commit
e838c6d47d
@ -29,10 +29,8 @@ namespace MCGalaxy.Commands
|
||||
public override void Use(Player p, string message) {
|
||||
if (p == null) { MessageInGameOnly(p); return; }
|
||||
|
||||
int x = (ushort)(p.pos[0] / 32);
|
||||
int y = (ushort)((p.pos[1] / 32) - 1);
|
||||
int z = (ushort)(p.pos[2] / 32);
|
||||
Command.all.Find("click").Use(p, x + " " + y + " " + z);
|
||||
Vec3U16 P = Vec3U16.ClampPosToBounds(p.pos[0], (ushort)(p.pos[1] - 32), p.pos[2], p.level);
|
||||
Command.all.Find("click").Use(p, (P.X / 32) + " " + (P.Y / 32) + " " + (P.Z / 32));
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
|
@ -76,6 +76,7 @@ namespace MCGalaxy {
|
||||
return new Vec3U16(Math.Min(a.X, b.X), Math.Min(a.Y, b.Y), Math.Min(a.Z, b.Z));
|
||||
}
|
||||
|
||||
/// <summary> Clamps the given block coordinates to inside the map. </summary>
|
||||
public static Vec3U16 ClampToBounds(ushort x, ushort y, ushort z, Level lvl) {
|
||||
Vec3U16 P = new Vec3U16(x, y, z);
|
||||
if (P.X >= 32768) P.X = 0;
|
||||
@ -88,6 +89,19 @@ namespace MCGalaxy {
|
||||
return P;
|
||||
}
|
||||
|
||||
/// <summary> Clamps the given player position coordinates to inside the map. </summary>
|
||||
public static Vec3U16 ClampPosToBounds(ushort x, ushort y, ushort z, Level lvl) {
|
||||
Vec3U16 P = new Vec3U16(x, y, z);
|
||||
if (P.X >= 32768) P.X = 0;
|
||||
if (P.Y >= 32768) P.Y = 0;
|
||||
if (P.Z >= 32768) P.Z = 0;
|
||||
|
||||
if (P.X >= lvl.Width * 32) P.X = (ushort)(32 * lvl.Width - 32);
|
||||
if (P.Y >= lvl.Height * 32) P.Y = (ushort)(32 * lvl.Height - 32);
|
||||
if (P.Z >= lvl.Length * 32) P.Z = (ushort)(32 * lvl.Length - 32);
|
||||
return P;
|
||||
}
|
||||
|
||||
public static bool operator == (Vec3U16 a, Vec3U16 b) {
|
||||
return a.X == b.X && a.Y == b.Y && a.Z == b.Z;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user