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/BeaconTileEntity.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'Minecraft.World/BeaconTileEntity.cpp') diff --git a/Minecraft.World/BeaconTileEntity.cpp b/Minecraft.World/BeaconTileEntity.cpp index d80eb906..633930f4 100644 --- a/Minecraft.World/BeaconTileEntity.cpp +++ b/Minecraft.World/BeaconTileEntity.cpp @@ -10,7 +10,7 @@ shared_ptr BeaconTileEntity::clone() { - shared_ptr result = shared_ptr( new BeaconTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->primaryPower = primaryPower; @@ -28,7 +28,7 @@ void BeaconTileEntity::staticCtor() { for(unsigned int effect = 0; effect < BEACON_EFFECTS_EFFECTS; ++effect) { - BEACON_EFFECTS[tier][effect] = NULL; + BEACON_EFFECTS[tier][effect] = nullptr; } } BEACON_EFFECTS[0][0] = MobEffect::movementSpeed; @@ -163,18 +163,18 @@ float BeaconTileEntity::getAndUpdateClientSideScale() return 0; } - int renderDelta = (int) (level->getGameTime() - clientSideRenderTick); + int renderDelta = static_cast(level->getGameTime() - clientSideRenderTick); clientSideRenderTick = level->getGameTime(); if (renderDelta > 1) { - clientSideRenderScale -= ((float) renderDelta / (float) SCALE_TIME); + clientSideRenderScale -= (static_cast(renderDelta) / static_cast(SCALE_TIME)); if (clientSideRenderScale < 0) { clientSideRenderScale = 0; } } - clientSideRenderScale += (1.0f / (float) SCALE_TIME); + clientSideRenderScale += (1.0f / static_cast(SCALE_TIME)); if (clientSideRenderScale > 1) { clientSideRenderScale = 1; @@ -213,7 +213,7 @@ void BeaconTileEntity::setPrimaryPower(int primaryPower) for(unsigned int e = 0; e < BEACON_EFFECTS_EFFECTS; ++e) { MobEffect *effect = BEACON_EFFECTS[tier][e]; - if(effect == NULL) break; + if(effect == nullptr) break; if (effect->id == primaryPower) { @@ -236,7 +236,7 @@ void BeaconTileEntity::setSecondaryPower(int secondaryPower) for(unsigned int e = 0; e < BEACON_EFFECTS_EFFECTS; ++e) { MobEffect *effect = BEACON_EFFECTS[tier][e]; - if(effect == NULL) break; + if(effect == nullptr) break; if (effect->id == secondaryPower) { @@ -252,7 +252,7 @@ shared_ptr BeaconTileEntity::getUpdatePacket() { CompoundTag *tag = new CompoundTag(); save(tag); - return shared_ptr( new TileEntityDataPacket(x, y, z, TileEntityDataPacket::TYPE_BEACON, tag) ); + return std::make_shared(x, y, z, TileEntityDataPacket::TYPE_BEACON, tag); } double BeaconTileEntity::getViewDistance() @@ -295,7 +295,7 @@ shared_ptr BeaconTileEntity::getItem(unsigned int slot) shared_ptr BeaconTileEntity::removeItem(unsigned int slot, int count) { - if (slot == 0 && paymentItem != NULL) + if (slot == 0 && paymentItem != nullptr) { if (count >= paymentItem->count) { @@ -306,7 +306,7 @@ shared_ptr BeaconTileEntity::removeItem(unsigned int slot, int cou else { paymentItem->count -= count; - return shared_ptr( new ItemInstance(paymentItem->id, count, paymentItem->getAuxValue()) ); + return std::make_shared(paymentItem->id, count, paymentItem->getAuxValue()); } } return nullptr; @@ -314,7 +314,7 @@ shared_ptr BeaconTileEntity::removeItem(unsigned int slot, int cou shared_ptr BeaconTileEntity::removeItemNoUpdate(int slot) { - if (slot == 0 && paymentItem != NULL) + if (slot == 0 && paymentItem != nullptr) { shared_ptr returnItem = paymentItem; paymentItem = nullptr; -- cgit v1.2.3