aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/Pig.cpp
diff options
context:
space:
mode:
authorModMaker101 <119018978+ModMaker101@users.noreply.github.com>2026-03-08 19:08:36 -0400
committerGitHub <noreply@github.com>2026-03-08 18:08:36 -0500
commit28614b922fb77149a54da1a87bebfbc98736f296 (patch)
tree7f828ba86a4ee18d0a80d29de64f6199a5412512 /Minecraft.World/Pig.cpp
parent88798b501d0cf6287b6f87acb2592676e3cec58d (diff)
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
Diffstat (limited to 'Minecraft.World/Pig.cpp')
-rw-r--r--Minecraft.World/Pig.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/Minecraft.World/Pig.cpp b/Minecraft.World/Pig.cpp
index cc042f58..a99af826 100644
--- a/Minecraft.World/Pig.cpp
+++ b/Minecraft.World/Pig.cpp
@@ -64,13 +64,13 @@ bool Pig::canBeControlledByRider()
{
shared_ptr<ItemInstance> item = dynamic_pointer_cast<Player>(rider.lock())->getCarriedItem();
- return item != NULL && item->id == Item::carrotOnAStick_Id;
+ return item != nullptr && item->id == Item::carrotOnAStick_Id;
}
void Pig::defineSynchedData()
{
Animal::defineSynchedData();
- entityData->define(DATA_SADDLE_ID, (byte) 0);
+ entityData->define(DATA_SADDLE_ID, static_cast<byte>(0));
}
void Pig::addAdditonalSaveData(CompoundTag *tag)
@@ -109,7 +109,7 @@ bool Pig::mobInteract(shared_ptr<Player> player)
{
if(!Animal::mobInteract(player))
{
- if (hasSaddle() && !level->isClientSide && (rider.lock() == NULL || rider.lock() == player))
+ if (hasSaddle() && !level->isClientSide && (rider.lock() == nullptr || 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() );
@@ -153,18 +153,18 @@ void Pig::setSaddle(bool value)
{
if (value)
{
- entityData->set(DATA_SADDLE_ID, (byte) 1);
+ entityData->set(DATA_SADDLE_ID, static_cast<byte>(1));
}
else
{
- entityData->set(DATA_SADDLE_ID, (byte) 0);
+ entityData->set(DATA_SADDLE_ID, static_cast<byte>(0));
}
}
void Pig::thunderHit(const LightningBolt *lightningBolt)
{
if (level->isClientSide) return;
- shared_ptr<PigZombie> pz = shared_ptr<PigZombie>( new PigZombie(level) );
+ shared_ptr<PigZombie> pz = std::make_shared<PigZombie>(level);
pz->moveTo(x, y, z, yRot, xRot);
level->addEntity(pz);
remove();
@@ -173,7 +173,7 @@ void Pig::thunderHit(const LightningBolt *lightningBolt)
void Pig::causeFallDamage(float distance)
{
Animal::causeFallDamage(distance);
- if ( (distance > 5) && rider.lock() != NULL && rider.lock()->instanceof(eTYPE_PLAYER) )
+ if ( (distance > 5) && rider.lock() != nullptr && rider.lock()->instanceof(eTYPE_PLAYER) )
{
(dynamic_pointer_cast<Player>(rider.lock()))->awardStat(GenericStats::flyPig(),GenericStats::param_flyPig());
}
@@ -184,7 +184,7 @@ shared_ptr<AgableMob> Pig::getBreedOffspring(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::make_shared<Pig>(level);
}
else
{
@@ -194,7 +194,7 @@ shared_ptr<AgableMob> Pig::getBreedOffspring(shared_ptr<AgableMob> target)
bool Pig::isFood(shared_ptr<ItemInstance> itemInstance)
{
- return itemInstance != NULL && itemInstance->id == Item::carrots_Id;
+ return itemInstance != nullptr && itemInstance->id == Item::carrots_Id;
}
ControlledByPlayerGoal *Pig::getControlGoal()