diff options
| author | Loki Rautio <lokirautio@gmail.com> | 2026-03-04 03:56:03 -0600 |
|---|---|---|
| committer | Loki Rautio <lokirautio@gmail.com> | 2026-03-04 03:56:03 -0600 |
| commit | 42aec6dac53dffa6afe072560a7e1d4986112538 (patch) | |
| tree | 0836426857391df1b6a83f6368a183f83ec9b104 /Minecraft.World/Pos.cpp | |
| parent | c9d58eeac7c72f0b3038e084667b4d89a6249fce (diff) | |
| parent | ef9b6fd500dfabd9463267b0dd9e29577eea8a2b (diff) | |
Merge branch 'main' into pr/win64-world-saves
# Conflicts:
# Minecraft.Client/MinecraftServer.cpp
# README.md
Diffstat (limited to 'Minecraft.World/Pos.cpp')
| -rw-r--r-- | Minecraft.World/Pos.cpp | 67 |
1 files changed, 36 insertions, 31 deletions
diff --git a/Minecraft.World/Pos.cpp b/Minecraft.World/Pos.cpp index 3fad76e8..e673ecc3 100644 --- a/Minecraft.World/Pos.cpp +++ b/Minecraft.World/Pos.cpp @@ -18,9 +18,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 @@ -71,9 +71,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() @@ -145,93 +145,93 @@ 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; + x += steps; } void Pos::moveY(int steps) { - this->y += steps; + y += steps; } void Pos::moveZ(int steps) { - this->z += steps; + z += steps; } void Pos::moveUp(int steps) { - this->y += steps; + y += steps; } void Pos::moveUp() { - this->y++; + y++; } void Pos::moveDown(int steps) { - this->y -= steps; + y -= steps; } void Pos::moveDown() { - this->y--; + y--; } void Pos::moveEast(int steps) { - this->x += steps; + x += steps; } void Pos::moveEast() { - this->x++; + x++; } void Pos::moveWest(int steps) { - this->x -= steps; + x -= steps; } void Pos::moveWest() { - this->x--; + x--; } void Pos::moveNorth(int steps) { - this->z -= steps; + z -= steps; } void Pos::moveNorth() { - this->z--; + z--; } void Pos::moveSouth(int steps) { - this->z += steps; + z += steps; } void Pos::moveSouth() { - this->z++; + 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) @@ -241,8 +241,13 @@ double Pos::dist(Pos *pos) 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); }
\ No newline at end of file |
