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/SpawnEggItem.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'Minecraft.World/SpawnEggItem.cpp') diff --git a/Minecraft.World/SpawnEggItem.cpp b/Minecraft.World/SpawnEggItem.cpp index 9c059126..5124f668 100644 --- a/Minecraft.World/SpawnEggItem.cpp +++ b/Minecraft.World/SpawnEggItem.cpp @@ -16,7 +16,7 @@ SpawnEggItem::SpawnEggItem(int id) : Item(id) { setMaxStackSize(16); // 4J-PB brought forward. It is 64 on PC, but we'll never be able to place that many setStackedByData(true); - overlay = NULL; + overlay = nullptr; } wstring SpawnEggItem::getHoverName(shared_ptr itemInstance) @@ -69,7 +69,7 @@ Icon *SpawnEggItem::getLayerIcon(int auxValue, int spriteLayer) shared_ptr SpawnEggItem::canSpawn(int iAuxVal, Level *level, int *piResult) { shared_ptr newEntity = EntityIO::newById(iAuxVal, level); - if (newEntity != NULL) + if (newEntity != nullptr) { bool canSpawn = false; @@ -200,7 +200,7 @@ bool SpawnEggItem::useOn(shared_ptr itemInstance, shared_ptrremoveTile(x,y,z); level->setTileAndData(x,y,z,Tile::mobSpawner_Id, 0, Tile::UPDATE_ALL); shared_ptr mste = dynamic_pointer_cast( level->getTileEntity(x,y,z) ); - if(mste != NULL) + if(mste != nullptr) { mste->setEntityId( EntityIO::getEncodeId(itemInstance->getAuxValue()) ); return true; @@ -213,7 +213,7 @@ bool SpawnEggItem::useOn(shared_ptr itemInstance, shared_ptrgetRenderShape() == Tile::SHAPE_FENCE)) + if (face == Facing::UP && (Tile::tiles[tile] != nullptr && Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_FENCE)) { // special case yOff = .5; @@ -224,10 +224,10 @@ bool SpawnEggItem::useOn(shared_ptr itemInstance, shared_ptrinstanceof(eTYPE_MOB) && itemInstance->hasCustomHoverName() ) @@ -252,7 +252,7 @@ shared_ptr SpawnEggItem::use(shared_ptr itemInstance if (level->isClientSide) return itemInstance; HitResult *hr = getPlayerPOVHitResult(level, player, true); - if (hr == NULL) + if (hr == nullptr) { delete hr; return itemInstance; @@ -275,7 +275,7 @@ shared_ptr SpawnEggItem::use(shared_ptr itemInstance { int iResult=0; shared_ptr result = spawnMobAt(level, itemInstance->getAuxValue(), xt, yt, zt, &iResult); - if (result != NULL) + if (result != nullptr) { // 4J-JEV: SetCustomName is a method for Mob not LivingEntity; so change instanceof to check for Mobs. if ( result->instanceof(eTYPE_MOB) && itemInstance->hasCustomHoverName() ) @@ -317,7 +317,7 @@ shared_ptr SpawnEggItem::spawnMobAt(Level *level, int auxVal, double x, newEntity = canSpawn(mobId, level, piResult); // 4J-JEV: DynCasting to Mob not LivingEntity; so change instanceof to check for Mobs. - if ( newEntity != NULL && newEntity->instanceof(eTYPE_MOB) ) + if ( newEntity != nullptr && newEntity->instanceof(eTYPE_MOB) ) { shared_ptr mob = dynamic_pointer_cast(newEntity); newEntity->moveTo(x, y, z, Mth::wrapDegrees(level->random->nextFloat() * 360), 0); @@ -325,7 +325,7 @@ shared_ptr SpawnEggItem::spawnMobAt(Level *level, int auxVal, double x, mob->yHeadRot = mob->yRot; mob->yBodyRot = mob->yRot; - mob->finalizeMobSpawn(NULL, extraData); + mob->finalizeMobSpawn(nullptr, extraData); level->addEntity(newEntity); mob->playAmbientSound(); } -- cgit v1.2.3