aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/ControlledByPlayerGoal.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/ControlledByPlayerGoal.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/ControlledByPlayerGoal.cpp')
-rw-r--r--Minecraft.World/ControlledByPlayerGoal.cpp12
1 files changed, 6 insertions, 6 deletions
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> player = dynamic_pointer_cast<Player>(mob->rider.lock());
- PathfinderMob *pig = (PathfinderMob *)mob;
+ PathfinderMob *pig = static_cast<PathfinderMob *>(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<float>(boostTime) / boostTimeTotal * PI);
}
float friction = 0.91f;
@@ -117,13 +117,13 @@ void ControlledByPlayerGoal::tick()
{
shared_ptr<ItemInstance> 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<ItemInstance> replacement = shared_ptr<ItemInstance>(new ItemInstance(Item::fishingRod));
+ shared_ptr<ItemInstance> replacement = std::make_shared<ItemInstance>(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<HalfSlabTile *>(Tile::tiles[tile]) != NULL) );
+ return Tile::tiles[tile] != nullptr && (Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_STAIRS || (dynamic_cast<HalfSlabTile *>(Tile::tiles[tile]) != nullptr) );
}
bool ControlledByPlayerGoal::isBoosting()