TU19: merge Minecraft.World/Util

This commit is contained in:
Tropical
2026-03-21 17:37:16 -05:00
parent a1e4726296
commit eb23fc1a83
41 changed files with 1574 additions and 268 deletions

View File

@@ -11,9 +11,9 @@ Pos::Pos(int x, int y, int z) {
}
Pos::Pos(Pos* position) {
this->x = position->x;
this->y = position->y;
this->z = position->z;
x = position->x;
y = position->y;
z = position->z;
}
//@Override
@@ -54,9 +54,9 @@ void Pos::set(int x, int y, int z) {
}
void Pos::set(Pos* pos) {
this->x = pos->x;
this->y = pos->y;
this->z = pos->z;
x = pos->x;
y = pos->y;
z = pos->z;
}
Pos* Pos::above() { return new Pos(x, y + 1, z); }
@@ -90,54 +90,56 @@ void Pos::move(int x, int y, int z) {
}
void Pos::move(Pos pos) {
this->x += pos.x;
this->y += pos.y;
this->z += pos.z;
x += pos.x;
y += pos.y;
z += pos.z;
}
void Pos::moveX(int steps) { this->x += steps; }
void Pos::moveX(int steps) { x += steps; }
void Pos::moveY(int steps) { this->y += steps; }
void Pos::moveY(int steps) { y += steps; }
void Pos::moveZ(int steps) { this->z += steps; }
void Pos::moveZ(int steps) { z += steps; }
void Pos::moveUp(int steps) { this->y += steps; }
void Pos::moveUp(int steps) { y += steps; }
void Pos::moveUp() { this->y++; }
void Pos::moveUp() { y++; }
void Pos::moveDown(int steps) { this->y -= steps; }
void Pos::moveDown(int steps) { y -= steps; }
void Pos::moveDown() { this->y--; }
void Pos::moveDown() { y--; }
void Pos::moveEast(int steps) { this->x += steps; }
void Pos::moveEast(int steps) { x += steps; }
void Pos::moveEast() { this->x++; }
void Pos::moveEast() { x++; }
void Pos::moveWest(int steps) { this->x -= steps; }
void Pos::moveWest(int steps) { x -= steps; }
void Pos::moveWest() { this->x--; }
void Pos::moveWest() { x--; }
void Pos::moveNorth(int steps) { this->z -= steps; }
void Pos::moveNorth(int steps) { z -= steps; }
void Pos::moveNorth() { this->z--; }
void Pos::moveNorth() { z--; }
void Pos::moveSouth(int steps) { this->z += steps; }
void Pos::moveSouth(int steps) { z += steps; }
void Pos::moveSouth() { this->z++; }
void Pos::moveSouth() { z++; }
double Pos::dist(int x, int y, int z) {
int dx = this->x - x;
int dy = this->y - y;
int dz = this->z - z;
double dx = this->x - x;
double dy = this->y - y;
double dz = this->z - z;
return sqrt((double)dx * dx + dy * dy + dz * dz);
return sqrt(dx * dx + dy * dy + dz * dz);
}
double Pos::dist(Pos* pos) { return dist(pos->x, pos->y, pos->z); }
float Pos::distSqr(int x, int y, int z) {
int dx = this->x - x;
int dy = this->y - y;
int dz = this->z - z;
float dx = this->x - x;
float dy = this->y - y;
float dz = this->z - z;
return dx * dx + dy * dy + dz * dz;
}
}
float Pos::distSqr(Pos* pos) { return distSqr(pos->x, pos->y, pos->z); }