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/FurnaceTileEntity.cpp | 42 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'Minecraft.World/FurnaceTileEntity.cpp') diff --git a/Minecraft.World/FurnaceTileEntity.cpp b/Minecraft.World/FurnaceTileEntity.cpp index 1aa2c300..901235c0 100644 --- a/Minecraft.World/FurnaceTileEntity.cpp +++ b/Minecraft.World/FurnaceTileEntity.cpp @@ -53,7 +53,7 @@ shared_ptr FurnaceTileEntity::removeItem(unsigned int slot, int co { m_charcoalUsed = false; - if (items[slot] != NULL) + if (items[slot] != nullptr) { if (items[slot]->count <= count) { @@ -79,7 +79,7 @@ shared_ptr FurnaceTileEntity::removeItemNoUpdate(int slot) { m_charcoalUsed = false; - if (items[slot] != NULL) + if (items[slot] != nullptr) { shared_ptr item = items[slot]; items[slot] = nullptr; @@ -92,7 +92,7 @@ shared_ptr FurnaceTileEntity::removeItemNoUpdate(int slot) void FurnaceTileEntity::setItem(unsigned int slot, shared_ptr item) { items[slot] = item; - if (item != NULL && item->count > getMaxStackSize()) item->count = getMaxStackSize(); + if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize(); } @@ -140,16 +140,16 @@ void FurnaceTileEntity::load(CompoundTag *base) void FurnaceTileEntity::save(CompoundTag *base) { TileEntity::save(base); - base->putShort(L"BurnTime", (short) (litTime)); - base->putShort(L"CookTime", (short) (tickCount)); + base->putShort(L"BurnTime", static_cast(litTime)); + base->putShort(L"CookTime", static_cast(tickCount)); ListTag *listTag = new ListTag(); for (unsigned int i = 0; i < items.length; i++) { - if (items[i] != NULL) + if (items[i] != nullptr) { CompoundTag *tag = new CompoundTag(); - tag->putByte(L"Slot", (byte) i); + tag->putByte(L"Slot", static_cast(i)); items[i]->save(tag); listTag->add(tag); } @@ -194,7 +194,7 @@ void FurnaceTileEntity::tick() litTime--; } - if ( level != NULL && !level->isClientSide) + if ( level != nullptr && !level->isClientSide) { if (litTime == 0 && canBurn()) { @@ -202,7 +202,7 @@ void FurnaceTileEntity::tick() if (litTime > 0) { changed = true; - if (items[SLOT_FUEL] != NULL) + if (items[SLOT_FUEL] != nullptr) { // 4J Added: Keep track of whether charcoal was used in production of current stack. if ( items[SLOT_FUEL]->getItem()->id == Item::coal_Id @@ -215,7 +215,7 @@ void FurnaceTileEntity::tick() if (items[SLOT_FUEL]->count == 0) { Item *remaining = items[SLOT_FUEL]->getItem()->getCraftingRemainingItem(); - items[SLOT_FUEL] = remaining != NULL ? shared_ptr(new ItemInstance(remaining)) : nullptr; + items[SLOT_FUEL] = remaining != nullptr ? std::make_shared(remaining) : nullptr; } } } @@ -249,10 +249,10 @@ void FurnaceTileEntity::tick() bool FurnaceTileEntity::canBurn() { - if (items[SLOT_INPUT] == NULL) return false; + if (items[SLOT_INPUT] == nullptr) return false; const ItemInstance *burnResult = FurnaceRecipes::getInstance()->getResult(items[SLOT_INPUT]->getItem()->id); - if (burnResult == NULL) return false; - if (items[SLOT_RESULT] == NULL) return true; + if (burnResult == nullptr) return false; + if (items[SLOT_RESULT] == nullptr) return true; if (!items[SLOT_RESULT]->sameItem_not_shared(burnResult)) return false; if (items[SLOT_RESULT]->count < getMaxStackSize() && items[SLOT_RESULT]->count < items[SLOT_RESULT]->getMaxStackSize()) return true; if (items[SLOT_RESULT]->count < burnResult->getMaxStackSize()) return true; @@ -265,7 +265,7 @@ void FurnaceTileEntity::burn() if (!canBurn()) return; const ItemInstance *result = FurnaceRecipes::getInstance()->getResult(items[SLOT_INPUT]->getItem()->id); - if (items[SLOT_RESULT] == NULL) items[SLOT_RESULT] = result->copy(); + if (items[SLOT_RESULT] == nullptr) items[SLOT_RESULT] = result->copy(); else if (items[SLOT_RESULT]->id == result->id) items[SLOT_RESULT]->count++; items[SLOT_INPUT]->count--; @@ -275,12 +275,12 @@ void FurnaceTileEntity::burn() int FurnaceTileEntity::getBurnDuration(shared_ptr itemInstance) { - if (itemInstance == NULL) return 0; + if (itemInstance == nullptr) return 0; int id = itemInstance->getItem()->id; Item *item = itemInstance->getItem(); - if (id < 256 && Tile::tiles[id] != NULL) + if (id < 256 && Tile::tiles[id] != nullptr) { Tile *tile = Tile::tiles[id]; @@ -300,15 +300,15 @@ int FurnaceTileEntity::getBurnDuration(shared_ptr itemInstance) } } - if (dynamic_cast(item) && ((DiggerItem *) item)->getTier() == Item::Tier::WOOD) + if (dynamic_cast(item) && static_cast(item)->getTier() == Item::Tier::WOOD) { return BURN_INTERVAL; } - else if (dynamic_cast(item) && ((WeaponItem *) item)->getTier() == Item::Tier::WOOD) + else if (dynamic_cast(item) && static_cast(item)->getTier() == Item::Tier::WOOD) { return BURN_INTERVAL; } - else if (dynamic_cast(item) && ((HoeItem *) item)->getTier() == Item::Tier::WOOD) + else if (dynamic_cast(item) && static_cast(item)->getTier() == Item::Tier::WOOD) { return BURN_INTERVAL; } @@ -396,7 +396,7 @@ bool FurnaceTileEntity::canTakeItemThroughFace(int slot, shared_ptr FurnaceTileEntity::clone() { - shared_ptr result = shared_ptr( new FurnaceTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->litTime = litTime; @@ -405,7 +405,7 @@ shared_ptr FurnaceTileEntity::clone() for (unsigned int i = 0; i < items.length; i++) { - if (items[i] != NULL) + if (items[i] != nullptr) { result->items[i] = ItemInstance::clone(items[i]); } -- cgit v1.2.3