aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/Pig.cpp
diff options
context:
space:
mode:
authorvoid_17 <heroerror3@gmail.com>2026-03-02 15:58:20 +0700
committervoid_17 <heroerror3@gmail.com>2026-03-02 15:58:20 +0700
commit7074f35e4ba831e358117842b99ee35b87f85ae5 (patch)
tree7d440d23473196af3056bf2ff4c59d9e740a06f5 /Minecraft.World/Pig.cpp
parentd63f79325f85e014361eb8cf1e41eaebedb1ae71 (diff)
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.
Diffstat (limited to 'Minecraft.World/Pig.cpp')
-rw-r--r--Minecraft.World/Pig.cpp40
1 files changed, 20 insertions, 20 deletions
diff --git a/Minecraft.World/Pig.cpp b/Minecraft.World/Pig.cpp
index b556a936..21086365 100644
--- a/Minecraft.World/Pig.cpp
+++ b/Minecraft.World/Pig.cpp
@@ -56,49 +56,49 @@ int Pig::getMaxHealth()
bool Pig::canBeControlledByRider()
{
- shared_ptr<ItemInstance> item = dynamic_pointer_cast<Player>(rider.lock())->getCarriedItem();
+ std::shared_ptr<ItemInstance> item = dynamic_pointer_cast<Player>(rider.lock())->getCarriedItem();
return item != NULL && item->id == Item::carrotOnAStick_Id;
}
-void Pig::defineSynchedData()
+void Pig::defineSynchedData()
{
Animal::defineSynchedData();
entityData->define(DATA_SADDLE_ID, (byte) 0);
}
-void Pig::addAdditonalSaveData(CompoundTag *tag)
+void Pig::addAdditonalSaveData(CompoundTag *tag)
{
Animal::addAdditonalSaveData(tag);
tag->putBoolean(L"Saddle", hasSaddle());
}
-void Pig::readAdditionalSaveData(CompoundTag *tag)
+void Pig::readAdditionalSaveData(CompoundTag *tag)
{
Animal::readAdditionalSaveData(tag);
setSaddle(tag->getBoolean(L"Saddle"));
}
-int Pig::getAmbientSound()
+int Pig::getAmbientSound()
{
return eSoundType_MOB_PIG_AMBIENT;
}
-int Pig::getHurtSound()
+int Pig::getHurtSound()
{
return eSoundType_MOB_PIG_AMBIENT;
}
-int Pig::getDeathSound()
+int Pig::getDeathSound()
{
return eSoundType_MOB_PIG_DEATH;
}
-bool Pig::interact(shared_ptr<Player> player)
+bool Pig::interact(std::shared_ptr<Player> player)
{
if(!Animal::interact(player))
{
- if (hasSaddle() && !level->isClientSide && (rider.lock() == NULL || rider.lock() == player))
+ if (hasSaddle() && !level->isClientSide && (rider.lock() == NULL || rider.lock() == player))
{
// 4J HEG - Fixed issue with player not being able to dismount pig (issue #4479)
player->ride( rider.lock() == player ? nullptr : shared_from_this() );
@@ -109,7 +109,7 @@ bool Pig::interact(shared_ptr<Player> player)
return true;
}
-int Pig::getDeathLoot()
+int Pig::getDeathLoot()
{
if (this->isOnFire() ) return Item::porkChop_cooked->id;
return Item::porkChop_raw_Id;
@@ -133,18 +133,18 @@ void Pig::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel)
if (hasSaddle()) spawnAtLocation(Item::saddle_Id, 1);
}
-bool Pig::hasSaddle()
+bool Pig::hasSaddle()
{
return (entityData->getByte(DATA_SADDLE_ID) & 1) != 0;
}
-void Pig::setSaddle(bool value)
+void Pig::setSaddle(bool value)
{
- if (value)
+ if (value)
{
entityData->set(DATA_SADDLE_ID, (byte) 1);
- }
- else
+ }
+ else
{
entityData->set(DATA_SADDLE_ID, (byte) 0);
}
@@ -153,13 +153,13 @@ void Pig::setSaddle(bool value)
void Pig::thunderHit(const LightningBolt *lightningBolt)
{
if (level->isClientSide) return;
- shared_ptr<PigZombie> pz = shared_ptr<PigZombie>( new PigZombie(level) );
+ std::shared_ptr<PigZombie> pz = std::shared_ptr<PigZombie>( new PigZombie(level) );
pz->moveTo(x, y, z, yRot, xRot);
level->addEntity(pz);
remove();
}
-void Pig::causeFallDamage(float distance)
+void Pig::causeFallDamage(float distance)
{
Animal::causeFallDamage(distance);
if (distance > 5 && dynamic_pointer_cast<Player>( rider.lock() ) != NULL)
@@ -168,12 +168,12 @@ void Pig::causeFallDamage(float distance)
}
}
-shared_ptr<AgableMob> Pig::getBreedOffspring(shared_ptr<AgableMob> target)
+std::shared_ptr<AgableMob> Pig::getBreedOffspring(std::shared_ptr<AgableMob> target)
{
// 4J - added limit to number of animals that can be bred
if( level->canCreateMore( GetType(), Level::eSpawnType_Breed) )
{
- return shared_ptr<Pig>( new Pig(level) );
+ return std::shared_ptr<Pig>( new Pig(level) );
}
else
{
@@ -181,7 +181,7 @@ shared_ptr<AgableMob> Pig::getBreedOffspring(shared_ptr<AgableMob> target)
}
}
-bool Pig::isFood(shared_ptr<ItemInstance> itemInstance)
+bool Pig::isFood(std::shared_ptr<ItemInstance> itemInstance)
{
return itemInstance != NULL && itemInstance->id == Item::carrots_Id;
}