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/JukeboxTile.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/JukeboxTile.cpp')
| -rw-r--r-- | Minecraft.World/JukeboxTile.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Minecraft.World/JukeboxTile.cpp b/Minecraft.World/JukeboxTile.cpp index cf53a751..74e79e9e 100644 --- a/Minecraft.World/JukeboxTile.cpp +++ b/Minecraft.World/JukeboxTile.cpp @@ -23,7 +23,7 @@ void JukeboxTile::Entity::load(CompoundTag *tag) } else if (tag->getInt(L"Record") > 0) { - setRecord(shared_ptr<ItemInstance>( new ItemInstance(tag->getInt(L"Record"), 1, 0))); + setRecord(std::make_shared<ItemInstance>(tag->getInt(L"Record"), 1, 0)); } } @@ -31,7 +31,7 @@ void JukeboxTile::Entity::save(CompoundTag *tag) { TileEntity::save(tag); - if (getRecord() != NULL) + if (getRecord() != nullptr) { tag->putCompound(L"RecordItem", getRecord()->save(new CompoundTag())); @@ -42,7 +42,7 @@ void JukeboxTile::Entity::save(CompoundTag *tag) // 4J Added shared_ptr<TileEntity> JukeboxTile::Entity::clone() { - shared_ptr<JukeboxTile::Entity> result = shared_ptr<JukeboxTile::Entity>( new JukeboxTile::Entity() ); + shared_ptr<JukeboxTile::Entity> result = std::make_shared<JukeboxTile::Entity>(); TileEntity::clone(result); result->record = record; @@ -63,7 +63,7 @@ void JukeboxTile::Entity::setRecord(shared_ptr<ItemInstance> record) JukeboxTile::JukeboxTile(int id) : BaseEntityTile(id, Material::wood) { - iconTop = NULL; + iconTop = nullptr; } Icon *JukeboxTile::getTexture(int face, int data) @@ -107,10 +107,10 @@ void JukeboxTile::dropRecording(Level *level, int x, int y, int z) if (level->isClientSide) return; shared_ptr<JukeboxTile::Entity> rte = dynamic_pointer_cast<JukeboxTile::Entity>( level->getTileEntity(x, y, z) ); - if( rte == NULL ) return; + if( rte == nullptr ) return; shared_ptr<ItemInstance> oldRecord = rte->getRecord(); - if (oldRecord == NULL) return; + if (oldRecord == nullptr) return; level->levelEvent(LevelEvent::SOUND_PLAY_RECORDING, x, y, z, 0); @@ -127,7 +127,7 @@ void JukeboxTile::dropRecording(Level *level, int x, int y, int z) shared_ptr<ItemInstance> itemInstance = oldRecord->copy(); - shared_ptr<ItemEntity> item = shared_ptr<ItemEntity>( new ItemEntity(level, x + xo, y + yo, z + zo, itemInstance ) ); + shared_ptr<ItemEntity> item = std::make_shared<ItemEntity>(level, x + xo, y + yo, z + zo, itemInstance); item->throwTime = 10; level->addEntity(item); } @@ -146,7 +146,7 @@ void JukeboxTile::spawnResources(Level *level, int x, int y, int z, int data, fl shared_ptr<TileEntity> JukeboxTile::newTileEntity(Level *level) { - return shared_ptr<JukeboxTile::Entity>( new JukeboxTile::Entity() ); + return std::make_shared<JukeboxTile::Entity>(); } void JukeboxTile::registerIcons(IconRegister *iconRegister) @@ -163,5 +163,5 @@ bool JukeboxTile::hasAnalogOutputSignal() int JukeboxTile::getAnalogOutputSignal(Level *level, int x, int y, int z, int dir) { shared_ptr<ItemInstance> record = dynamic_pointer_cast<JukeboxTile::Entity>( level->getTileEntity(x, y, z))->getRecord(); - return record == NULL ? Redstone::SIGNAL_NONE : record->id + 1 - Item::record_01_Id; + return record == nullptr ? Redstone::SIGNAL_NONE : record->id + 1 - Item::record_01_Id; }
\ No newline at end of file |
