aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/MoveThroughVillageGoal.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/MoveThroughVillageGoal.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/MoveThroughVillageGoal.cpp')
-rw-r--r--Minecraft.World/MoveThroughVillageGoal.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/Minecraft.World/MoveThroughVillageGoal.cpp b/Minecraft.World/MoveThroughVillageGoal.cpp
index f112c109..81476aec 100644
--- a/Minecraft.World/MoveThroughVillageGoal.cpp
+++ b/Minecraft.World/MoveThroughVillageGoal.cpp
@@ -11,7 +11,7 @@
MoveThroughVillageGoal::MoveThroughVillageGoal(PathfinderMob *mob, double speedModifier, bool onlyAtNight)
{
- path = NULL;
+ path = nullptr;
doorInfo = weak_ptr<DoorInfo>();
this->mob = mob;
@@ -22,7 +22,7 @@ MoveThroughVillageGoal::MoveThroughVillageGoal(PathfinderMob *mob, double speedM
MoveThroughVillageGoal::~MoveThroughVillageGoal()
{
- if(path != NULL) delete path;
+ if(path != nullptr) delete path;
}
bool MoveThroughVillageGoal::canUse()
@@ -32,10 +32,10 @@ bool MoveThroughVillageGoal::canUse()
if (onlyAtNight && mob->level->isDay()) return false;
shared_ptr<Village> village = mob->level->villages->getClosestVillage(Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z), 0);
- if (village == NULL) return false;
+ if (village == nullptr) return false;
shared_ptr<DoorInfo> _doorInfo = getNextDoorInfo(village);
- if (_doorInfo == NULL) return false;
+ if (_doorInfo == nullptr) return false;
doorInfo = _doorInfo;
bool oldCanOpenDoors = mob->getNavigation()->canOpenDoors();
@@ -44,15 +44,15 @@ bool MoveThroughVillageGoal::canUse()
path = mob->getNavigation()->createPath(_doorInfo->x, _doorInfo->y, _doorInfo->z);
mob->getNavigation()->setCanOpenDoors(oldCanOpenDoors);
- if (path != NULL) return true;
+ if (path != nullptr) return true;
Vec3 *pos = RandomPos::getPosTowards(dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 10, 7, Vec3::newTemp(_doorInfo->x, _doorInfo->y, _doorInfo->z));
- if (pos == NULL) return false;
+ if (pos == nullptr) return false;
mob->getNavigation()->setCanOpenDoors(false);
delete path;
path = mob->getNavigation()->createPath(pos->x, pos->y, pos->z);
mob->getNavigation()->setCanOpenDoors(oldCanOpenDoors);
- return path != NULL;
+ return path != nullptr;
}
bool MoveThroughVillageGoal::canContinueToUse()
@@ -60,7 +60,7 @@ bool MoveThroughVillageGoal::canContinueToUse()
if (mob->getNavigation()->isDone()) return false;
float dist = mob->bbWidth + 4.f;
shared_ptr<DoorInfo> _doorInfo = doorInfo.lock();
- if( _doorInfo == NULL ) return false;
+ if( _doorInfo == nullptr ) return false;
return mob->distanceToSqr(_doorInfo->x, _doorInfo->y, _doorInfo->z) > dist * dist;
}
@@ -68,13 +68,13 @@ bool MoveThroughVillageGoal::canContinueToUse()
void MoveThroughVillageGoal::start()
{
mob->getNavigation()->moveTo(path, speedModifier);
- path = NULL;
+ path = nullptr;
}
void MoveThroughVillageGoal::stop()
{
shared_ptr<DoorInfo> _doorInfo = doorInfo.lock();
- if( _doorInfo == NULL ) return;
+ if( _doorInfo == nullptr ) return;
if (mob->getNavigation()->isDone() || mob->distanceToSqr(_doorInfo->x, _doorInfo->y, _doorInfo->z) < 4 * 4)
{