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/LeashFenceKnotEntity.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Minecraft.World/LeashFenceKnotEntity.cpp') diff --git a/Minecraft.World/LeashFenceKnotEntity.cpp b/Minecraft.World/LeashFenceKnotEntity.cpp index 55947d04..f94bcba7 100644 --- a/Minecraft.World/LeashFenceKnotEntity.cpp +++ b/Minecraft.World/LeashFenceKnotEntity.cpp @@ -70,14 +70,14 @@ bool LeashFenceKnotEntity::interact(shared_ptr player) shared_ptr item = player->getCarriedItem(); bool attachedMob = false; - if (item != NULL && item->id == Item::lead_Id) + if (item != nullptr && item->id == Item::lead_Id) { if (!level->isClientSide) { // look for entities that can be attached to the fence double range = 7; vector > *mobs = level->getEntitiesOfClass(typeid(Mob), AABB::newTemp(x - range, y - range, z - range, x + range, y + range, z + range)); - if (mobs != NULL) + if (mobs != nullptr) { for(auto& it : *mobs) { @@ -101,7 +101,7 @@ bool LeashFenceKnotEntity::interact(shared_ptr player) // if the player is in creative mode, attempt to remove all leashed mobs without dropping additional items double range = 7; vector > *mobs = level->getEntitiesOfClass(typeid(Mob), AABB::newTemp(x - range, y - range, z - range, x + range, y + range, z + range)); - if (mobs != NULL) + if (mobs != nullptr) { for(auto& it : *mobs) { @@ -122,7 +122,7 @@ bool LeashFenceKnotEntity::survives() { // knots are placed on top of fence tiles int tile = level->getTile(xTile, yTile, zTile); - if (Tile::tiles[tile] != NULL && Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_FENCE) + if (Tile::tiles[tile] != nullptr && Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_FENCE) { return true; } @@ -131,7 +131,7 @@ bool LeashFenceKnotEntity::survives() shared_ptr LeashFenceKnotEntity::createAndAddKnot(Level *level, int x, int y, int z) { - shared_ptr knot = shared_ptr( new LeashFenceKnotEntity(level, x, y, z) ); + shared_ptr knot = std::make_shared(level, x, y, z); knot->forcedLoading = true; level->addEntity(knot); return knot; @@ -140,7 +140,7 @@ shared_ptr LeashFenceKnotEntity::createAndAddKnot(Level *l shared_ptr LeashFenceKnotEntity::findKnotAt(Level *level, int x, int y, int z) { vector > *knots = level->getEntitiesOfClass(typeid(LeashFenceKnotEntity), AABB::newTemp(x - 1.0, y - 1.0, z - 1.0, x + 1.0, y + 1.0, z + 1.0)); - if (knots != NULL) + if (knots != nullptr) { for (auto& it : *knots ) { -- cgit v1.2.3