mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 12:42:22 -04:00
Make /chain use DirUtils too.
This commit is contained in:
parent
dddf8fd5b9
commit
32259898b6
@ -28,11 +28,7 @@ namespace MCGalaxy.BlockBehaviour {
|
|||||||
int dx = 0, dy = 0, dz = 0;
|
int dx = 0, dy = 0, dz = 0;
|
||||||
p.RevertBlock(x, y, z);
|
p.RevertBlock(x, y, z);
|
||||||
DirUtils.EightYaw(p.rot[0], out dx, out dz);
|
DirUtils.EightYaw(p.rot[0], out dx, out dz);
|
||||||
|
DirUtils.Pitch(p.rot[1], out dy);
|
||||||
if ( p.rot[1] >= 192 && p.rot[1] <= ( 192 + 32 ) )
|
|
||||||
dy = 1;
|
|
||||||
else if ( p.rot[1] <= 64 && p.rot[1] >= 32 )
|
|
||||||
dy = -1;
|
|
||||||
|
|
||||||
// Looking straight up or down
|
// Looking straight up or down
|
||||||
if (p.rot[1] >= 192 && p.rot[1] <= 196 || p.rot[1] >= 60 && p.rot[1] <= 64) { dx = 0; dz = 0; }
|
if (p.rot[1] >= 192 && p.rot[1] <= 196 || p.rot[1] >= 60 && p.rot[1] <= 64) { dx = 0; dz = 0; }
|
||||||
|
@ -34,15 +34,14 @@ namespace MCGalaxy.Commands
|
|||||||
Player.Message(p, "You cannot build on this map!"); return;
|
Player.Message(p, "You cannot build on this map!"); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int yaw = p.rot[0];
|
|
||||||
Level lvl = p.level;
|
Level lvl = p.level;
|
||||||
ushort x = (ushort)(p.pos[0] / 32), y = (ushort)(p.pos[1] / 32), z = (ushort)(p.pos[2] / 32);
|
ushort x = (ushort)(p.pos[0] / 32), y = (ushort)(p.pos[1] / 32), z = (ushort)(p.pos[2] / 32);
|
||||||
if (x >= lvl.Width || z >= lvl.Length) {
|
if (x >= lvl.Width || z >= lvl.Length) {
|
||||||
Player.Message(p, "You must be inside the map to use this command."); return;
|
Player.Message(p, "You must be inside the map to use this command."); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dirX = (yaw > 16 && yaw <= 112) ? 1 : (yaw > 144 && yaw <= 240) ? -1 : 0;
|
int dirX = 0, dirZ = 0;
|
||||||
int dirZ = (yaw > 208 || yaw < 48) ? -1 : (yaw > 80 && yaw <= 176) ? 1 : 0;
|
DirUtils.EightYaw(p.rot[0], out dirX, out dirZ);
|
||||||
DoChain(p, x, y, z, dirX, dirZ);
|
DoChain(p, x, y, z, dirX, dirZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
public static class DirUtils {
|
public static class DirUtils {
|
||||||
|
|
||||||
/* How yaw works: * How pitch works:
|
/* How yaw works: * How pitch works:
|
||||||
* 64 | +X * 192 | +Y
|
* 64 | +X * 192 | +Y
|
||||||
* ___|___ * |
|
* ___|___ * |
|
||||||
* / | \ * flipped |
|
* / | \ * flipped |
|
||||||
@ -37,7 +37,7 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
public static void EightYaw(byte yaw, out int dirX, out int dirZ) {
|
public static void EightYaw(byte yaw, out int dirX, out int dirZ) {
|
||||||
dirX = 0; dirZ = 0;
|
dirX = 0; dirZ = 0;
|
||||||
const byte extent = 48;
|
const byte extent = (64 / 4) * 3;
|
||||||
|
|
||||||
if (yaw < (0 + extent) || yaw > (256 - extent))
|
if (yaw < (0 + extent) || yaw > (256 - extent))
|
||||||
dirZ = -1;
|
dirZ = -1;
|
||||||
@ -52,7 +52,7 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
public static void FourYaw(byte yaw, out int dirX, out int dirZ) {
|
public static void FourYaw(byte yaw, out int dirX, out int dirZ) {
|
||||||
dirX = 0; dirZ = 0;
|
dirX = 0; dirZ = 0;
|
||||||
const byte quadrant = 32;
|
const byte quadrant = 64 / 2;
|
||||||
|
|
||||||
if (yaw <= (0 + quadrant) || yaw >= (256 - quadrant))
|
if (yaw <= (0 + quadrant) || yaw >= (256 - quadrant))
|
||||||
dirZ = -1;
|
dirZ = -1;
|
||||||
@ -63,5 +63,15 @@ namespace MCGalaxy {
|
|||||||
else
|
else
|
||||||
dirX = -1;
|
dirX = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Pitch(byte pitch, out int dirY) {
|
||||||
|
dirY = 0;
|
||||||
|
const byte quadrant = 32;
|
||||||
|
|
||||||
|
if (pitch >= 192 && pitch <= (192 + quadrant))
|
||||||
|
dirY = 1;
|
||||||
|
else if (pitch >= (64 - quadrant) && pitch <= 64)
|
||||||
|
dirY = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace MCGalaxy {
|
namespace MCGalaxy {
|
||||||
public struct Vec3U16 : IEquatable<Vec3U16> {
|
public struct Vec3U16 : IEquatable<Vec3U16> {
|
||||||
public ushort X, Y, Z;
|
public ushort X, Y, Z;
|
||||||
public static Vec3U16 Zero = new Vec3U16(0);
|
public static Vec3U16 Zero = new Vec3U16(0);
|
||||||
public static Vec3U16 MinVal = new Vec3U16(ushort.MinValue);
|
public static Vec3U16 MinVal = new Vec3U16(ushort.MinValue);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user