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/BrewingStandTileEntity.cpp | 44 +++++++++++++++--------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'Minecraft.World/BrewingStandTileEntity.cpp') diff --git a/Minecraft.World/BrewingStandTileEntity.cpp b/Minecraft.World/BrewingStandTileEntity.cpp index 20cb3737..98334f78 100644 --- a/Minecraft.World/BrewingStandTileEntity.cpp +++ b/Minecraft.World/BrewingStandTileEntity.cpp @@ -79,7 +79,7 @@ bool BrewingStandTileEntity::isBrewable() { return false; } - shared_ptr ingredient = items[INGREDIENT_SLOT]; + std::shared_ptr ingredient = items[INGREDIENT_SLOT]; if (PotionBrewing::SIMPLIFIED_BREWING) { if (!Item::items[ingredient->id]->hasPotionBrewingFormula()) @@ -135,7 +135,7 @@ bool BrewingStandTileEntity::isBrewable() } else { - if (!Item::items[ingredient->id]->hasPotionBrewingFormula() && ingredient->id != Item::bucket_water_Id && ingredient->id != Item::netherStalkSeeds_Id) + if (!Item::items[ingredient->id]->hasPotionBrewingFormula() && ingredient->id != Item::bucket_water_Id && ingredient->id != Item::netherStalkSeeds_Id) { return false; } @@ -172,7 +172,7 @@ void BrewingStandTileEntity::doBrew() return; } - shared_ptr ingredient = items[INGREDIENT_SLOT]; + std::shared_ptr ingredient = items[INGREDIENT_SLOT]; if (PotionBrewing::SIMPLIFIED_BREWING) { @@ -233,14 +233,14 @@ void BrewingStandTileEntity::doBrew() } else if (isWater && items[dest] != NULL && items[dest]->id == Item::glassBottle_Id) { - items[dest] = shared_ptr(new ItemInstance(Item::potion)); + items[dest] = std::shared_ptr(new ItemInstance(Item::potion)); } } } if (Item::items[ingredient->id]->hasCraftingRemainingItem()) { - items[INGREDIENT_SLOT] = shared_ptr(new ItemInstance(Item::items[ingredient->id]->getCraftingRemainingItem())); + items[INGREDIENT_SLOT] = std::shared_ptr(new ItemInstance(Item::items[ingredient->id]->getCraftingRemainingItem())); } else { @@ -252,7 +252,7 @@ void BrewingStandTileEntity::doBrew() } } -int BrewingStandTileEntity::applyIngredient(int currentBrew, shared_ptr ingredient) +int BrewingStandTileEntity::applyIngredient(int currentBrew, std::shared_ptr ingredient) { if (ingredient == NULL) { @@ -278,7 +278,7 @@ int BrewingStandTileEntity::applyIngredient(int currentBrew, shared_ptrputByte(L"Slot", (byte) i); @@ -316,7 +316,7 @@ void BrewingStandTileEntity::save(CompoundTag *base) base->put(L"Items", listTag); } -shared_ptr BrewingStandTileEntity::getItem(unsigned int slot) +std::shared_ptr BrewingStandTileEntity::getItem(unsigned int slot) { if (slot >= 0 && slot < items.length) { @@ -325,7 +325,7 @@ shared_ptr BrewingStandTileEntity::getItem(unsigned int slot) return nullptr; } -shared_ptr BrewingStandTileEntity::removeItem(unsigned int slot, int count) +std::shared_ptr BrewingStandTileEntity::removeItem(unsigned int slot, int count) { // 4J Stu - Changed the implementation of this function to be the same as ChestTileEntity to enable the "Pickup Half" // option on the ingredients slot @@ -333,18 +333,18 @@ shared_ptr BrewingStandTileEntity::removeItem(unsigned int slot, i if (slot >= 0 && slot < items.length && items[slot] != NULL) { - if (items[slot]->count <= count) + if (items[slot]->count <= count) { - shared_ptr item = items[slot]; + std::shared_ptr item = items[slot]; items[slot] = nullptr; this->setChanged(); // 4J Stu - Fix for duplication glitch if(item->count <= 0) return nullptr; return item; - } - else + } + else { - shared_ptr i = items[slot]->remove(count); + std::shared_ptr i = items[slot]->remove(count); if (items[slot]->count == 0) items[slot] = nullptr; this->setChanged(); // 4J Stu - Fix for duplication glitch @@ -354,19 +354,19 @@ shared_ptr BrewingStandTileEntity::removeItem(unsigned int slot, i } return nullptr; } - -shared_ptr BrewingStandTileEntity::removeItemNoUpdate(int slot) + +std::shared_ptr BrewingStandTileEntity::removeItemNoUpdate(int slot) { if (slot >= 0 && slot < items.length) { - shared_ptr item = items[slot]; + std::shared_ptr item = items[slot]; items[slot] = nullptr; return item; } return nullptr; } -void BrewingStandTileEntity::setItem(unsigned int slot, shared_ptr item) +void BrewingStandTileEntity::setItem(unsigned int slot, std::shared_ptr item) { if (slot >= 0 && slot < items.length) { @@ -379,7 +379,7 @@ int BrewingStandTileEntity::getMaxStackSize() return 1; } -bool BrewingStandTileEntity::stillValid(shared_ptr player) +bool BrewingStandTileEntity::stillValid(std::shared_ptr player) { if (level->getTileEntity(x, y, z) != shared_from_this()) return false; if (player->distanceToSqr(x + 0.5, y + 0.5, z + 0.5) > 8 * 8) return false; @@ -413,9 +413,9 @@ int BrewingStandTileEntity::getPotionBits() } // 4J Added -shared_ptr BrewingStandTileEntity::clone() +std::shared_ptr BrewingStandTileEntity::clone() { - shared_ptr result = shared_ptr( new BrewingStandTileEntity() ); + std::shared_ptr result = std::shared_ptr( new BrewingStandTileEntity() ); TileEntity::clone(result); result->brewTime = brewTime; -- cgit v1.2.3