aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/DoorInteractGoal.cpp
diff options
context:
space:
mode:
authorModMaker101 <119018978+ModMaker101@users.noreply.github.com>2026-03-08 19:08:36 -0400
committerGitHub <noreply@github.com>2026-03-08 18:08:36 -0500
commit28614b922fb77149a54da1a87bebfbc98736f296 (patch)
tree7f828ba86a4ee18d0a80d29de64f6199a5412512 /Minecraft.World/DoorInteractGoal.cpp
parent88798b501d0cf6287b6f87acb2592676e3cec58d (diff)
Modernize project codebase (#906)
* Fixed boats falling and a TP glitch #266 * Replaced every C-style cast with C++ ones * Replaced every C-style cast with C++ ones * Fixed boats falling and a TP glitch #266 * Updated NULL to nullptr and fixing some type issues * Modernized and fixed a few bugs - Replaced most instances of `NULL` with `nullptr`. - Replaced most `shared_ptr(new ...)` with `make_shared`. - Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances. * Fixing more conflicts * Replace int loops with size_t and start work on overrides * Add safety checks and fix a issue with vector going OOR
Diffstat (limited to 'Minecraft.World/DoorInteractGoal.cpp')
-rw-r--r--Minecraft.World/DoorInteractGoal.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/Minecraft.World/DoorInteractGoal.cpp b/Minecraft.World/DoorInteractGoal.cpp
index 1e3bfe11..45805744 100644
--- a/Minecraft.World/DoorInteractGoal.cpp
+++ b/Minecraft.World/DoorInteractGoal.cpp
@@ -9,7 +9,7 @@
DoorInteractGoal::DoorInteractGoal(Mob *mob)
{
doorX = doorY = doorZ = 0;
- doorTile = NULL;
+ doorTile = nullptr;
passed = false;
doorOpenDirX = doorOpenDirZ = 0.0f;
@@ -21,7 +21,7 @@ bool DoorInteractGoal::canUse()
if (!mob->horizontalCollision) return false;
PathNavigation *pathNav = mob->getNavigation();
Path *path = pathNav->getPath();
- if (path == NULL || path->isDone() || !pathNav->canOpenDoors()) return false;
+ if (path == nullptr || path->isDone() || !pathNav->canOpenDoors()) return false;
for (int i = 0; i < min(path->getIndex() + 2, path->getSize()); ++i)
{
@@ -31,7 +31,7 @@ bool DoorInteractGoal::canUse()
doorZ = n->z;
if (mob->distanceToSqr(doorX, mob->y, doorZ) > 1.5 * 1.5) continue;
doorTile = getDoorTile(doorX, doorY, doorZ);
- if (doorTile == NULL) continue;
+ if (doorTile == nullptr) continue;
return true;
}
@@ -39,7 +39,7 @@ bool DoorInteractGoal::canUse()
doorY = Mth::floor(mob->y + 1);
doorZ = Mth::floor(mob->z);
doorTile = getDoorTile(doorX, doorY, doorZ);
- return doorTile != NULL;
+ return doorTile != nullptr;
}
bool DoorInteractGoal::canContinueToUse()
@@ -50,14 +50,14 @@ bool DoorInteractGoal::canContinueToUse()
void DoorInteractGoal::start()
{
passed = false;
- doorOpenDirX = (float) (doorX + 0.5f - mob->x);
- doorOpenDirZ = (float) (doorZ + 0.5f - mob->z);
+ doorOpenDirX = static_cast<float>(doorX + 0.5f - mob->x);
+ doorOpenDirZ = static_cast<float>(doorZ + 0.5f - mob->z);
}
void DoorInteractGoal::tick()
{
- float newDoorDirX = (float) (doorX + 0.5f - mob->x);
- float newDoorDirZ = (float) (doorZ + 0.5f - mob->z);
+ float newDoorDirX = static_cast<float>(doorX + 0.5f - mob->x);
+ float newDoorDirZ = static_cast<float>(doorZ + 0.5f - mob->z);
float dot = doorOpenDirX * newDoorDirX + doorOpenDirZ * newDoorDirZ;
if (dot < 0)
{
@@ -68,6 +68,6 @@ void DoorInteractGoal::tick()
DoorTile *DoorInteractGoal::getDoorTile(int x, int y, int z)
{
int tileId = mob->level->getTile(x, y, z);
- if (tileId != Tile::door_wood_Id) return NULL;
- return (DoorTile *) Tile::tiles[tileId];
+ if (tileId != Tile::door_wood_Id) return nullptr;
+ return static_cast<DoorTile *>(Tile::tiles[tileId]);
} \ No newline at end of file