diff options
| author | ModMaker101 <119018978+ModMaker101@users.noreply.github.com> | 2026-03-08 19:08:36 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-08 18:08:36 -0500 |
| commit | 28614b922fb77149a54da1a87bebfbc98736f296 (patch) | |
| tree | 7f828ba86a4ee18d0a80d29de64f6199a5412512 /Minecraft.World/FurnaceTile.cpp | |
| parent | 88798b501d0cf6287b6f87acb2592676e3cec58d (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/FurnaceTile.cpp')
| -rw-r--r-- | Minecraft.World/FurnaceTile.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/Minecraft.World/FurnaceTile.cpp b/Minecraft.World/FurnaceTile.cpp index d22d6ca7..d8856f4e 100644 --- a/Minecraft.World/FurnaceTile.cpp +++ b/Minecraft.World/FurnaceTile.cpp @@ -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); } |
