From a9be52c41a02d207233199e98898fe7483d7e817 Mon Sep 17 00:00:00 2001 From: ModMaker101 <119018978+ModMaker101@users.noreply.github.com> Date: Sat, 7 Mar 2026 21:56:03 -0500 Subject: 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 --- Minecraft.World/JukeboxTile.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'Minecraft.World/JukeboxTile.cpp') 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( new ItemInstance(tag->getInt(L"Record"), 1, 0))); + setRecord(std::make_shared(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 JukeboxTile::Entity::clone() { - shared_ptr result = shared_ptr( new JukeboxTile::Entity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->record = record; @@ -63,7 +63,7 @@ void JukeboxTile::Entity::setRecord(shared_ptr 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 rte = dynamic_pointer_cast( level->getTileEntity(x, y, z) ); - if( rte == NULL ) return; + if( rte == nullptr ) return; shared_ptr 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 = oldRecord->copy(); - shared_ptr item = shared_ptr( new ItemEntity(level, x + xo, y + yo, z + zo, itemInstance ) ); + shared_ptr item = std::make_shared(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 JukeboxTile::newTileEntity(Level *level) { - return shared_ptr( new JukeboxTile::Entity() ); + return std::make_shared(); } 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 record = dynamic_pointer_cast( 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 -- cgit v1.2.3