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/SkullTile.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/SkullTile.cpp')
| -rw-r--r-- | Minecraft.World/SkullTile.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/Minecraft.World/SkullTile.cpp b/Minecraft.World/SkullTile.cpp index 92ce7807..b5eca373 100644 --- a/Minecraft.World/SkullTile.cpp +++ b/Minecraft.World/SkullTile.cpp @@ -67,7 +67,7 @@ void SkullTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr<Living shared_ptr<TileEntity> SkullTile::newTileEntity(Level *level) { - return shared_ptr<SkullTileEntity>(new SkullTileEntity()); + return std::make_shared<SkullTileEntity>(); } int SkullTile::cloneTileId(Level *level, int x, int y, int z) @@ -79,7 +79,7 @@ int SkullTile::cloneTileData(Level *level, int x, int y, int z) { shared_ptr<TileEntity> tileEntity = level->getTileEntity(x, y, z); shared_ptr<SkullTileEntity> skull = dynamic_pointer_cast<SkullTileEntity>(tileEntity); - if (skull != NULL) + if (skull != nullptr) { return skull->getSkullType(); } @@ -113,7 +113,7 @@ void SkullTile::onRemove(Level *level, int x, int y, int z, int id, int data) if (level->isClientSide) return; if ((data & NO_DROP_BIT) == 0) { - shared_ptr<ItemInstance> item = shared_ptr<ItemInstance>(new ItemInstance(Item::skull_Id, 1, cloneTileData(level, x, y, z))); + shared_ptr<ItemInstance> item = std::make_shared<ItemInstance>(Item::skull_Id, 1, cloneTileData(level, x, y, z)); shared_ptr<SkullTileEntity> entity = dynamic_pointer_cast<SkullTileEntity>(level->getTileEntity(x, y, z)); if (entity->getSkullType() == SkullTileEntity::TYPE_CHAR && !entity->getExtraType().empty()) @@ -166,7 +166,7 @@ void SkullTile::checkMobSpawn(Level *level, int x, int y, int z, shared_ptr<Skul if (level->canCreateMore(eTYPE_WITHERBOSS, Level::eSpawnType_Egg)) { // 4J: Removed !isClientSide check because there's one earlier on - shared_ptr<WitherBoss> witherBoss = shared_ptr<WitherBoss>( new WitherBoss(level) ); + shared_ptr<WitherBoss> witherBoss = std::make_shared<WitherBoss>(level); witherBoss->moveTo(x + 0.5, y - 1.45, z + zo + 1.5, 90, 0); witherBoss->yBodyRot = 90; witherBoss->makeInvulnerable(); @@ -180,8 +180,8 @@ void SkullTile::checkMobSpawn(Level *level, int x, int y, int z, shared_ptr<Skul Tile::tiles[Tile::soulsand_Id]->spawnResources(level, x, y - 2, z + zo + 1, 0, 0); Tile::tiles[Tile::soulsand_Id]->spawnResources(level, x, y - 1, z + zo + 2, 0, 0); - shared_ptr<ItemInstance> itemInstance = shared_ptr<ItemInstance>(new ItemInstance(Item::skull_Id, 3, SkullTileEntity::TYPE_WITHER)); - shared_ptr<ItemEntity> itemEntity = shared_ptr<ItemEntity>(new ItemEntity(level, x, y, z + zo + 1, itemInstance) ); + shared_ptr<ItemInstance> itemInstance = std::make_shared<ItemInstance>(Item::skull_Id, 3, SkullTileEntity::TYPE_WITHER); + shared_ptr<ItemEntity> itemEntity = std::make_shared<ItemEntity>(level, x, y, z + zo + 1, itemInstance); level->addEntity(itemEntity); } @@ -229,7 +229,7 @@ void SkullTile::checkMobSpawn(Level *level, int x, int y, int z, shared_ptr<Skul if (level->canCreateMore(eTYPE_WITHERBOSS, Level::eSpawnType_Egg)) { // 4J: Removed !isClientSide check because there's one earlier on - shared_ptr<WitherBoss> witherBoss = shared_ptr<WitherBoss>( new WitherBoss(level) ); + shared_ptr<WitherBoss> witherBoss = std::make_shared<WitherBoss>(level); witherBoss->moveTo(x + xo + 1.5, y - 1.45, z + .5, 0, 0); witherBoss->makeInvulnerable(); level->addEntity(witherBoss); @@ -242,8 +242,8 @@ void SkullTile::checkMobSpawn(Level *level, int x, int y, int z, shared_ptr<Skul Tile::tiles[Tile::soulsand_Id]->spawnResources(level, x + xo + 1, y - 2, z, 0, 0); Tile::tiles[Tile::soulsand_Id]->spawnResources(level, x + xo + 2, y - 1, z, 0, 0); - shared_ptr<ItemInstance> itemInstance = shared_ptr<ItemInstance>(new ItemInstance(Item::skull_Id, 3, SkullTileEntity::TYPE_WITHER)); - shared_ptr<ItemEntity> itemEntity = shared_ptr<ItemEntity>(new ItemEntity(level, x + xo + 1, y, z, itemInstance) ); + shared_ptr<ItemInstance> itemInstance = std::make_shared<ItemInstance>(Item::skull_Id, 3, SkullTileEntity::TYPE_WITHER); + shared_ptr<ItemEntity> itemEntity = std::make_shared<ItemEntity>(level, x + xo + 1, y, z, itemInstance); level->addEntity(itemEntity); } @@ -274,7 +274,7 @@ bool SkullTile::isSkullAt(Level *level, int x, int y, int z, int skullType) } shared_ptr<TileEntity> te = level->getTileEntity(x, y, z); shared_ptr<SkullTileEntity> skull = dynamic_pointer_cast<SkullTileEntity>(te); - if (skull == NULL) + if (skull == nullptr) { return false; } |
