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

@@ -31,7 +31,7 @@ ThrownPotion::ThrownPotion(Level *level, shared_ptr<LivingEntity> mob, int potio
{
_init();
potionItem = shared_ptr<ItemInstance>( new ItemInstance(Item::potion, 1, potionValue));
potionItem = std::make_shared<ItemInstance>(Item::potion, 1, potionValue);
}
ThrownPotion::ThrownPotion(Level *level, shared_ptr<LivingEntity> mob, shared_ptr<ItemInstance> potion) : Throwable(level, mob)
@@ -45,7 +45,7 @@ ThrownPotion::ThrownPotion(Level *level, double x, double y, double z, int potio
{
_init();
potionItem = shared_ptr<ItemInstance>( new ItemInstance(Item::potion, 1, potionValue));
potionItem = std::make_shared<ItemInstance>(Item::potion, 1, potionValue);
}
ThrownPotion::ThrownPotion(Level *level, double x, double y, double z, shared_ptr<ItemInstance> potion) : Throwable(level, x, y, z)
@@ -72,13 +72,13 @@ float ThrownPotion::getThrowUpAngleOffset()
void ThrownPotion::setPotionValue(int potionValue)
{
if (potionItem == NULL) potionItem = shared_ptr<ItemInstance>( new ItemInstance(Item::potion, 1, 0) );
if (potionItem == nullptr) potionItem = std::make_shared<ItemInstance>(Item::potion, 1, 0);
potionItem->setAuxValue(potionValue);
}
int ThrownPotion::getPotionValue()
{
if (potionItem == NULL) potionItem = shared_ptr<ItemInstance>( new ItemInstance(Item::potion, 1, 0) );
if (potionItem == nullptr) potionItem = std::make_shared<ItemInstance>(Item::potion, 1, 0);
return potionItem->getAuxValue();
}
@@ -88,12 +88,12 @@ void ThrownPotion::onHit(HitResult *res)
{
vector<MobEffectInstance *> *mobEffects = Item::potion->getMobEffects(potionItem);
if (mobEffects != NULL && !mobEffects->empty())
if (mobEffects != nullptr && !mobEffects->empty())
{
AABB *aoe = bb->grow(SPLASH_RANGE, SPLASH_RANGE / 2, SPLASH_RANGE);
vector<shared_ptr<Entity> > *entitiesOfClass = level->getEntitiesOfClass(typeid(LivingEntity), aoe);
if (entitiesOfClass != NULL && !entitiesOfClass->empty())
if (entitiesOfClass != nullptr && !entitiesOfClass->empty())
{
for(auto & it : *entitiesOfClass)
{
@@ -117,7 +117,7 @@ void ThrownPotion::onHit(HitResult *res)
}
else
{
int duration = (int) (scale * (double) effect->getDuration() + .5);
int duration = static_cast<int>(scale * (double)effect->getDuration() + .5);
if (duration > SharedConstants::TICKS_PER_SECOND)
{
e->addEffect(new MobEffectInstance(id, duration, effect->getAmplifier()));
@@ -129,7 +129,7 @@ void ThrownPotion::onHit(HitResult *res)
}
delete entitiesOfClass;
}
level->levelEvent(LevelEvent::PARTICLES_POTION_SPLASH, (int) Math::round(x), (int) Math::round(y), (int) Math::round(z), getPotionValue() );
level->levelEvent(LevelEvent::PARTICLES_POTION_SPLASH, static_cast<int>(Math::round(x)), static_cast<int>(Math::round(y)), static_cast<int>(Math::round(z)), getPotionValue() );
remove();
}
@@ -148,12 +148,12 @@ void ThrownPotion::readAdditionalSaveData(CompoundTag *tag)
setPotionValue(tag->getInt(L"potionValue"));
}
if (potionItem == NULL) remove();
if (potionItem == nullptr) remove();
}
void ThrownPotion::addAdditonalSaveData(CompoundTag *tag)
{
Throwable::addAdditonalSaveData(tag);
if (potionItem != NULL) tag->putCompound(L"Potion", potionItem->save(new CompoundTag()));
if (potionItem != nullptr) tag->putCompound(L"Potion", potionItem->save(new CompoundTag()));
}