mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-05-28 20:45:07 +00:00
TU19: merge Minecraft.World/Util
This commit is contained in:
@@ -6,6 +6,8 @@ const int Direction::STEP_X[] = {0, -1, 0, 1};
|
||||
|
||||
const int Direction::STEP_Z[] = {1, 0, -1, 0};
|
||||
|
||||
const std::wstring Direction::NAMES[] = {L"SOUTH", L"WEST", L"NORTH", L"EAST"};
|
||||
|
||||
// for [direction] it gives [tile-face]
|
||||
int Direction::DIRECTION_FACING[4] = {Facing::SOUTH, Facing::WEST,
|
||||
Facing::NORTH, Facing::EAST};
|
||||
@@ -14,16 +16,13 @@ int Direction::DIRECTION_FACING[4] = {Facing::SOUTH, Facing::WEST,
|
||||
int Direction::FACING_DIRECTION[] = {UNDEFINED, UNDEFINED, NORTH,
|
||||
SOUTH, WEST, EAST};
|
||||
|
||||
int Direction::DIRECTION_OPPOSITE[4] = {Direction::NORTH, Direction::EAST,
|
||||
Direction::SOUTH, Direction::WEST};
|
||||
int Direction::DIRECTION_OPPOSITE[4] = {NORTH, EAST, SOUTH, WEST};
|
||||
|
||||
// for [direction] it gives [90 degrees clockwise direction]
|
||||
int Direction::DIRECTION_CLOCKWISE[] = {Direction::WEST, Direction::NORTH,
|
||||
Direction::EAST, Direction::SOUTH};
|
||||
int Direction::DIRECTION_CLOCKWISE[] = {WEST, NORTH, EAST, SOUTH};
|
||||
|
||||
// for [direction] it gives [90 degrees counter clockwise direction]
|
||||
int Direction::DIRECTION_COUNTER_CLOCKWISE[] = {
|
||||
Direction::EAST, Direction::SOUTH, Direction::WEST, Direction::NORTH};
|
||||
int Direction::DIRECTION_COUNTER_CLOCKWISE[] = {EAST, SOUTH, WEST, NORTH};
|
||||
|
||||
int Direction::RELATIVE_DIRECTION_FACING[4][6] = {
|
||||
// south
|
||||
@@ -38,3 +37,26 @@ int Direction::RELATIVE_DIRECTION_FACING[4][6] = {
|
||||
// east
|
||||
{Facing::UP, Facing::DOWN, Facing::WEST, Facing::EAST, Facing::SOUTH,
|
||||
Facing::NORTH}};
|
||||
|
||||
int Direction::getDirection(double xd, double zd) {
|
||||
if (Mth::abs((float)xd) > Mth::abs((float)zd)) {
|
||||
if (xd > 0) {
|
||||
return WEST;
|
||||
} else {
|
||||
return EAST;
|
||||
}
|
||||
} else {
|
||||
if (zd > 0) {
|
||||
return NORTH;
|
||||
} else {
|
||||
return SOUTH;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int Direction::getDirection(int x0, int z0, int x1, int z1) {
|
||||
int xd = x0 - x1;
|
||||
int zd = z0 - z1;
|
||||
|
||||
return getDirection(xd, zd);
|
||||
}
|
||||
Reference in New Issue
Block a user