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

@@ -17,8 +17,8 @@ FurnaceTile::FurnaceTile(int id, bool lit) : BaseEntityTile(id, Material::stone)
random = new Random();
this->lit = lit;
iconTop = NULL;
iconFront = NULL;
iconTop = nullptr;
iconFront = nullptr;
}
int FurnaceTile::getResource(int data, Random *random, int playerBonusLevel)
@@ -117,7 +117,7 @@ bool FurnaceTile::use(Level *level, int x, int y, int z, shared_ptr<Player> play
return true;
}
shared_ptr<FurnaceTileEntity> furnace = dynamic_pointer_cast<FurnaceTileEntity>( level->getTileEntity(x, y, z) );
if (furnace != NULL ) player->openFurnace(furnace);
if (furnace != nullptr ) player->openFurnace(furnace);
return true;
}
@@ -132,7 +132,7 @@ void FurnaceTile::setLit(bool lit, Level *level, int x, int y, int z)
noDrop = false;
level->setData(x, y, z, data, Tile::UPDATE_CLIENTS);
if( te != NULL )
if( te != nullptr )
{
te->clearRemoved();
level->setTileEntity(x, y, z, te);
@@ -141,7 +141,7 @@ void FurnaceTile::setLit(bool lit, Level *level, int x, int y, int z)
shared_ptr<TileEntity> FurnaceTile::newTileEntity(Level *level)
{
return shared_ptr<FurnaceTileEntity>( new FurnaceTileEntity() );
return std::make_shared<FurnaceTileEntity>();
}
void FurnaceTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr<LivingEntity> by, shared_ptr<ItemInstance> itemInstance)
@@ -164,12 +164,12 @@ void FurnaceTile::onRemove(Level *level, int x, int y, int z, int id, int data)
if (!noDrop)
{
shared_ptr<Container> container = dynamic_pointer_cast<FurnaceTileEntity>( level->getTileEntity(x, y, z) );
if( container != NULL )
if( container != nullptr )
{
for (unsigned int i = 0; i < container->getContainerSize(); i++)
{
shared_ptr<ItemInstance> item = container->getItem(i);
if (item != NULL)
if (item != nullptr)
{
float xo = random->nextFloat() * 0.8f + 0.1f;
float yo = random->nextFloat() * 0.8f + 0.1f;
@@ -192,16 +192,16 @@ void FurnaceTile::onRemove(Level *level, int x, int y, int z, int id, int data)
}
#endif
shared_ptr<ItemInstance> newItem = shared_ptr<ItemInstance>( new ItemInstance(item->id, count, item->getAuxValue()) );
shared_ptr<ItemInstance> newItem = std::make_shared<ItemInstance>(item->id, count, item->getAuxValue());
newItem->set4JData( item->get4JData() );
shared_ptr<ItemEntity> itemEntity = shared_ptr<ItemEntity>( new ItemEntity(level, x + xo, y + yo, z + zo, newItem) );
shared_ptr<ItemEntity> itemEntity = std::make_shared<ItemEntity>(level, x + xo, y + yo, z + zo, newItem);
float pow = 0.05f;
itemEntity->xd = (float) random->nextGaussian() * pow;
itemEntity->yd = (float) random->nextGaussian() * pow + 0.2f;
itemEntity->zd = (float) random->nextGaussian() * pow;
itemEntity->xd = static_cast<float>(random->nextGaussian()) * pow;
itemEntity->yd = static_cast<float>(random->nextGaussian()) * pow + 0.2f;
itemEntity->zd = static_cast<float>(random->nextGaussian()) * pow;
if (item->hasTag())
{
itemEntity->getItem()->setTag((CompoundTag *) item->getTag()->copy());
itemEntity->getItem()->setTag(static_cast<CompoundTag *>(item->getTag()->copy()));
}
level->addEntity(itemEntity);
}