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/MinecartContainer.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'Minecraft.World/MinecartContainer.cpp') diff --git a/Minecraft.World/MinecartContainer.cpp b/Minecraft.World/MinecartContainer.cpp index 20bfc4ea..0e0fd3ac 100644 --- a/Minecraft.World/MinecartContainer.cpp +++ b/Minecraft.World/MinecartContainer.cpp @@ -33,7 +33,7 @@ void MinecartContainer::destroy(DamageSource *source) for (int i = 0; i < getContainerSize(); i++) { shared_ptr item = getItem(i); - if (item != NULL) + if (item != nullptr) { float xo = random->nextFloat() * 0.8f + 0.1f; float yo = random->nextFloat() * 0.8f + 0.1f; @@ -45,11 +45,11 @@ void MinecartContainer::destroy(DamageSource *source) if (count > item->count) count = item->count; item->count -= count; - shared_ptr itemEntity = shared_ptr( new ItemEntity(level, x + xo, y + yo, z + zo, shared_ptr( new ItemInstance(item->id, count, item->getAuxValue()))) ); + shared_ptr itemEntity = std::make_shared(level, x + xo, y + yo, z + zo, shared_ptr(new ItemInstance(item->id, count, item->getAuxValue()))); float pow = 0.05f; - itemEntity->xd = (float) random->nextGaussian() * pow; - itemEntity->yd = (float) random->nextGaussian() * pow + 0.2f; - itemEntity->zd = (float) random->nextGaussian() * pow; + itemEntity->xd = static_cast(random->nextGaussian()) * pow; + itemEntity->yd = static_cast(random->nextGaussian()) * pow + 0.2f; + itemEntity->zd = static_cast(random->nextGaussian()) * pow; level->addEntity(itemEntity); } } @@ -63,7 +63,7 @@ shared_ptr MinecartContainer::getItem(unsigned int slot) shared_ptr MinecartContainer::removeItem(unsigned int slot, int count) { - if (items[slot] != NULL) + if (items[slot] != nullptr) { if (items[slot]->count <= count) { @@ -83,7 +83,7 @@ shared_ptr MinecartContainer::removeItem(unsigned int slot, int co shared_ptr MinecartContainer::removeItemNoUpdate(int slot) { - if (items[slot] != NULL) + if (items[slot] != nullptr) { shared_ptr item = items[slot]; items[slot] = nullptr; @@ -95,7 +95,7 @@ shared_ptr MinecartContainer::removeItemNoUpdate(int slot) void MinecartContainer::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(); } void MinecartContainer::setChanged() @@ -145,7 +145,7 @@ void MinecartContainer::remove() for (int i = 0; i < getContainerSize(); i++) { shared_ptr item = getItem(i); - if (item != NULL) + if (item != nullptr) { float xo = random->nextFloat() * 0.8f + 0.1f; float yo = random->nextFloat() * 0.8f + 0.1f; @@ -157,17 +157,17 @@ void MinecartContainer::remove() if (count > item->count) count = item->count; item->count -= count; - shared_ptr itemEntity = shared_ptr( new ItemEntity(level, x + xo, y + yo, z + zo, shared_ptr( new ItemInstance(item->id, count, item->getAuxValue())))); + shared_ptr itemEntity = std::make_shared(level, x + xo, y + yo, z + zo, shared_ptr(new ItemInstance(item->id, count, item->getAuxValue()))); if (item->hasTag()) { - itemEntity->getItem()->setTag((CompoundTag *) item->getTag()->copy()); + itemEntity->getItem()->setTag(static_cast(item->getTag()->copy())); } float pow = 0.05f; - itemEntity->xd = (float) random->nextGaussian() * pow; - itemEntity->yd = (float) random->nextGaussian() * pow + 0.2f; - itemEntity->zd = (float) random->nextGaussian() * pow; + itemEntity->xd = static_cast(random->nextGaussian()) * pow; + itemEntity->yd = static_cast(random->nextGaussian()) * pow + 0.2f; + itemEntity->zd = static_cast(random->nextGaussian()) * pow; level->addEntity(itemEntity); } } @@ -185,10 +185,10 @@ void MinecartContainer::addAdditonalSaveData(CompoundTag *base) 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); } -- cgit v1.2.3