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/BrewingStandTileEntity.cpp | 42 +++++++++++++++--------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'Minecraft.World/BrewingStandTileEntity.cpp') diff --git a/Minecraft.World/BrewingStandTileEntity.cpp b/Minecraft.World/BrewingStandTileEntity.cpp index 5bc6fd27..3d081bae 100644 --- a/Minecraft.World/BrewingStandTileEntity.cpp +++ b/Minecraft.World/BrewingStandTileEntity.cpp @@ -96,7 +96,7 @@ int BrewingStandTileEntity::getBrewTime() bool BrewingStandTileEntity::isBrewable() { - if (items[INGREDIENT_SLOT] == NULL || items[INGREDIENT_SLOT]->count <= 0) + if (items[INGREDIENT_SLOT] == nullptr || items[INGREDIENT_SLOT]->count <= 0) { return false; } @@ -111,7 +111,7 @@ bool BrewingStandTileEntity::isBrewable() bool oneResult = false; for (int dest = 0; dest < 3; dest++) { - if (items[dest] != NULL && items[dest]->id == Item::potion_Id) + if (items[dest] != nullptr && items[dest]->id == Item::potion_Id) { int currentBrew = items[dest]->getAuxValue(); int newBrew = NORMALISE_POTION_AUXVAL( applyIngredient(currentBrew, ingredient) ); @@ -129,7 +129,7 @@ bool BrewingStandTileEntity::isBrewable() // TODO - find out whether actually checking pointers to MobEffectInstance classes for equality // is of any use bool equals = false; - if( ( currentEffects != NULL ) && ( newEffects != NULL ) ) + if( ( currentEffects != nullptr ) && ( newEffects != nullptr ) ) { if( currentEffects->size() == newEffects->size() ) { @@ -141,7 +141,7 @@ bool BrewingStandTileEntity::isBrewable() } if ((currentBrew > 0 && currentEffects == newEffects) || - (currentEffects != NULL && (equals || newEffects == NULL))) + (currentEffects != nullptr && (equals || newEffects == nullptr))) { } else if (currentBrew != newBrew) @@ -166,7 +166,7 @@ bool BrewingStandTileEntity::isBrewable() bool oneResult = false; for (int dest = 0; dest < 3; dest++) { - if (items[dest] != NULL && items[dest]->id == Item::potion_Id) + if (items[dest] != nullptr && items[dest]->id == Item::potion_Id) { int currentBrew = items[dest]->getAuxValue(); int newBrew = NORMALISE_POTION_AUXVAL( applyIngredient(currentBrew, ingredient) ); @@ -176,7 +176,7 @@ bool BrewingStandTileEntity::isBrewable() break; } } - else if (isWater && items[dest] != NULL && items[dest]->id == Item::glassBottle_Id) + else if (isWater && items[dest] != nullptr && items[dest]->id == Item::glassBottle_Id) { oneResult = true; break; @@ -199,7 +199,7 @@ void BrewingStandTileEntity::doBrew() { for (int dest = 0; dest < 3; dest++) { - if (items[dest] != NULL && items[dest]->id == Item::potion_Id) + if (items[dest] != nullptr && items[dest]->id == Item::potion_Id) { int currentBrew = items[dest]->getAuxValue(); int newBrew = NORMALISE_POTION_AUXVAL( applyIngredient(currentBrew, ingredient) ); @@ -211,7 +211,7 @@ void BrewingStandTileEntity::doBrew() // TODO - find out whether actually checking pointers to MobEffectInstance classes for equality // is of any use bool equals = false; - if( ( currentEffects != NULL ) && ( newEffects != NULL ) ) + if( ( currentEffects != nullptr ) && ( newEffects != nullptr ) ) { if( currentEffects->size() == newEffects->size() ) { @@ -223,7 +223,7 @@ void BrewingStandTileEntity::doBrew() } if ((currentBrew > 0 && currentEffects == newEffects) || - (currentEffects != NULL && (equals || newEffects == NULL))) + (currentEffects != nullptr && (equals || newEffects == nullptr))) { if (!PotionItem::isThrowable(currentBrew) && PotionItem::isThrowable(newBrew)) { @@ -246,22 +246,22 @@ void BrewingStandTileEntity::doBrew() for (int dest = 0; dest < 3; dest++) { - if (items[dest] != NULL && items[dest]->id == Item::potion_Id) + if (items[dest] != nullptr && items[dest]->id == Item::potion_Id) { int currentBrew = items[dest]->getAuxValue(); int newBrew = NORMALISE_POTION_AUXVAL( applyIngredient(currentBrew, ingredient) ); items[dest]->setAuxValue(newBrew); } - else if (isWater && items[dest] != NULL && items[dest]->id == Item::glassBottle_Id) + else if (isWater && items[dest] != nullptr && items[dest]->id == Item::glassBottle_Id) { - items[dest] = shared_ptr(new ItemInstance(Item::potion)); + items[dest] = std::make_shared(Item::potion); } } } if (Item::items[ingredient->id]->hasCraftingRemainingItem()) { - items[INGREDIENT_SLOT] = shared_ptr(new ItemInstance(Item::items[ingredient->id]->getCraftingRemainingItem())); + items[INGREDIENT_SLOT] = std::make_shared(Item::items[ingredient->id]->getCraftingRemainingItem()); } else { @@ -275,7 +275,7 @@ void BrewingStandTileEntity::doBrew() int BrewingStandTileEntity::applyIngredient(int currentBrew, shared_ptr ingredient) { - if (ingredient == NULL) + if (ingredient == nullptr) { return currentBrew; } @@ -322,15 +322,15 @@ void BrewingStandTileEntity::save(CompoundTag *base) { TileEntity::save(base); - base->putShort(L"BrewTime", (short) (brewTime)); + base->putShort(L"BrewTime", static_cast(brewTime)); ListTag *listTag = new ListTag(); for (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); } @@ -354,7 +354,7 @@ shared_ptr BrewingStandTileEntity::removeItem(unsigned int slot, i // option on the ingredients slot // Fix for #65373 - TU8: Content: UI: Command "Take Half" in the Brewing Stand interface doesn't work as intended. - if (slot >= 0 && slot < items.length && items[slot] != NULL) + if (slot >= 0 && slot < items.length && items[slot] != nullptr) { if (items[slot]->count <= count) { @@ -445,7 +445,7 @@ int BrewingStandTileEntity::getPotionBits() int newCount = 0; for (int potion = 0; potion < 3; potion++) { - if (items[potion] != NULL) + if (items[potion] != nullptr) { newCount |= (1 << potion); } @@ -476,7 +476,7 @@ bool BrewingStandTileEntity::canTakeItemThroughFace(int slot, shared_ptr BrewingStandTileEntity::clone() { - shared_ptr result = shared_ptr( new BrewingStandTileEntity() ); + shared_ptr result = std::make_shared(); TileEntity::clone(result); result->brewTime = brewTime; @@ -485,7 +485,7 @@ shared_ptr BrewingStandTileEntity::clone() for (unsigned int i = 0; i < items.length; i++) { - if (items.data[i] != NULL) + if (items.data[i] != nullptr) { result->items.data[i] = ItemInstance::clone(items.data[i]); } -- cgit v1.2.3