From 28614b922fb77149a54da1a87bebfbc98736f296 Mon Sep 17 00:00:00 2001 From: ModMaker101 <119018978+ModMaker101@users.noreply.github.com> Date: Sun, 8 Mar 2026 19:08:36 -0400 Subject: 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 --- Minecraft.World/ControlledByPlayerGoal.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Minecraft.World/ControlledByPlayerGoal.cpp') diff --git a/Minecraft.World/ControlledByPlayerGoal.cpp b/Minecraft.World/ControlledByPlayerGoal.cpp index cea227cd..c5203e6e 100644 --- a/Minecraft.World/ControlledByPlayerGoal.cpp +++ b/Minecraft.World/ControlledByPlayerGoal.cpp @@ -36,13 +36,13 @@ void ControlledByPlayerGoal::stop() bool ControlledByPlayerGoal::canUse() { - return mob->isAlive() && mob->rider.lock() != NULL && mob->rider.lock()->instanceof(eTYPE_PLAYER) && (boosting || mob->canBeControlledByRider()); + return mob->isAlive() && mob->rider.lock() != nullptr && mob->rider.lock()->instanceof(eTYPE_PLAYER) && (boosting || mob->canBeControlledByRider()); } void ControlledByPlayerGoal::tick() { shared_ptr player = dynamic_pointer_cast(mob->rider.lock()); - PathfinderMob *pig = (PathfinderMob *)mob; + PathfinderMob *pig = static_cast(mob); float yrd = Mth::wrapDegrees(player->yRot - mob->yRot) * 0.5f; if (yrd > 5) yrd = 5; @@ -62,7 +62,7 @@ void ControlledByPlayerGoal::tick() { boosting = false; } - moveSpeed += moveSpeed * 1.15f * Mth::sin((float) boostTime / boostTimeTotal * PI); + moveSpeed += moveSpeed * 1.15f * Mth::sin(static_cast(boostTime) / boostTimeTotal * PI); } float friction = 0.91f; @@ -117,13 +117,13 @@ void ControlledByPlayerGoal::tick() { shared_ptr carriedItem = player->getCarriedItem(); - if (carriedItem != NULL && carriedItem->id == Item::carrotOnAStick_Id) + if (carriedItem != nullptr && carriedItem->id == Item::carrotOnAStick_Id) { carriedItem->hurtAndBreak(1, player); if (carriedItem->count == 0) { - shared_ptr replacement = shared_ptr(new ItemInstance(Item::fishingRod)); + shared_ptr replacement = std::make_shared(Item::fishingRod); replacement->setTag(carriedItem->tag); player->inventory->items[player->inventory->selected] = replacement; } @@ -135,7 +135,7 @@ void ControlledByPlayerGoal::tick() bool ControlledByPlayerGoal::isNoJumpTile(int tile) { - return Tile::tiles[tile] != NULL && (Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_STAIRS || (dynamic_cast(Tile::tiles[tile]) != NULL) ); + return Tile::tiles[tile] != nullptr && (Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_STAIRS || (dynamic_cast(Tile::tiles[tile]) != nullptr) ); } bool ControlledByPlayerGoal::isBoosting() -- cgit v1.2.3