Project modernization (#630)

* 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
This commit is contained in:
ModMaker101
2026-03-07 21:56:03 -05:00
committed by GitHub
parent 1be5faaea7
commit a9be52c41a
1373 changed files with 19903 additions and 19449 deletions

View File

@@ -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()