From 7074f35e4ba831e358117842b99ee35b87f85ae5 Mon Sep 17 00:00:00 2001 From: void_17 Date: Mon, 2 Mar 2026 15:58:20 +0700 Subject: shared_ptr -> std::shared_ptr This is one of the first commits in a plan to remove all `using namespace std;` lines in the entire codebase as it is considered anti-pattern today. --- Minecraft.World/MonsterPlacerItem.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'Minecraft.World/MonsterPlacerItem.cpp') diff --git a/Minecraft.World/MonsterPlacerItem.cpp b/Minecraft.World/MonsterPlacerItem.cpp index a2970033..3c7809fe 100644 --- a/Minecraft.World/MonsterPlacerItem.cpp +++ b/Minecraft.World/MonsterPlacerItem.cpp @@ -18,7 +18,7 @@ MonsterPlacerItem::MonsterPlacerItem(int id) : Item(id) overlay = NULL; } -wstring MonsterPlacerItem::getHoverName(shared_ptr itemInstance) +wstring MonsterPlacerItem::getHoverName(std::shared_ptr itemInstance) { wstring elementName = getDescription(); @@ -29,14 +29,14 @@ wstring MonsterPlacerItem::getHoverName(shared_ptr itemInstance) //elementName += " " + I18n.get("entity." + encodeId + ".name"); } else - { + { elementName = replaceAll(elementName,L"{*CREATURE*}",L""); } return elementName; } -int MonsterPlacerItem::getColor(shared_ptr item, int spriteLayer) +int MonsterPlacerItem::getColor(std::shared_ptr item, int spriteLayer) { AUTO_VAR(it, EntityIO::idsSpawnableInCreative.find(item->getAuxValue())); if (it != EntityIO::idsSpawnableInCreative.end()) @@ -65,9 +65,9 @@ Icon *MonsterPlacerItem::getLayerIcon(int auxValue, int spriteLayer) } // 4J-PB - added for dispenser -shared_ptr MonsterPlacerItem::canSpawn(int iAuxVal, Level *level, int *piResult) +std::shared_ptr MonsterPlacerItem::canSpawn(int iAuxVal, Level *level, int *piResult) { - shared_ptr newEntity = EntityIO::newById(iAuxVal, level); + std::shared_ptr newEntity = EntityIO::newById(iAuxVal, level); if (newEntity != NULL) { bool canSpawn = false; @@ -166,7 +166,7 @@ shared_ptr MonsterPlacerItem::canSpawn(int iAuxVal, Level *level, int *p return nullptr; } -bool MonsterPlacerItem::useOn(shared_ptr itemInstance, shared_ptr player, Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly) +bool MonsterPlacerItem::useOn(std::shared_ptr itemInstance, std::shared_ptr player, Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly) { if (level->isClientSide) { @@ -181,7 +181,7 @@ bool MonsterPlacerItem::useOn(shared_ptr itemInstance, shared_ptr< // 4J Stu - Force adding this as a tile update level->setTile(x,y,z,0); level->setTile(x,y,z,Tile::mobSpawner_Id); - shared_ptr mste = dynamic_pointer_cast( level->getTileEntity(x,y,z) ); + std::shared_ptr mste = dynamic_pointer_cast( level->getTileEntity(x,y,z) ); if(mste != NULL) { mste->setEntityId( EntityIO::getEncodeId(itemInstance->getAuxValue()) ); @@ -193,7 +193,7 @@ bool MonsterPlacerItem::useOn(shared_ptr itemInstance, shared_ptr< x += Facing::STEP_X[face]; y += Facing::STEP_Y[face]; z += Facing::STEP_Z[face]; - + double yOff = 0; // 4J-PB - missing parentheses added if (face == Facing::UP && (tile == Tile::fence_Id || tile == Tile::netherFence_Id)) @@ -211,11 +211,11 @@ bool MonsterPlacerItem::useOn(shared_ptr itemInstance, shared_ptr< } if (spawned) - { + { if (!player->abilities.instabuild) { itemInstance->count--; - } + } } else { @@ -254,20 +254,20 @@ bool MonsterPlacerItem::useOn(shared_ptr itemInstance, shared_ptr< return true; } -shared_ptr MonsterPlacerItem::spawnMobAt(Level *level, int mobId, double x, double y, double z, int *piResult) +std::shared_ptr MonsterPlacerItem::spawnMobAt(Level *level, int mobId, double x, double y, double z, int *piResult) { if (EntityIO::idsSpawnableInCreative.find(mobId) == EntityIO::idsSpawnableInCreative.end()) { return nullptr; } - shared_ptr newEntity = nullptr; + std::shared_ptr newEntity = nullptr; for (int i = 0; i < SPAWN_COUNT; i++) { newEntity = canSpawn(mobId, level, piResult); - shared_ptr mob = dynamic_pointer_cast(newEntity); + std::shared_ptr mob = dynamic_pointer_cast(newEntity); if (mob) { newEntity->moveTo(x, y, z, Mth::wrapDegrees(level->random->nextFloat() * 360), 0); -- cgit v1.2.3