From 28614b922fb77149a54da1a87bebfbc98736f296 Mon Sep 17 00:00:00 2001 From: ModMaker101 <119018978+ModMaker101@users.noreply.github.com> Date: Sun, 8 Mar 2026 19:08:36 -0400 Subject: Modernize project codebase (#906) * 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 * Add safety checks and fix a issue with vector going OOR --- Minecraft.World/DispenserTile.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'Minecraft.World/DispenserTile.cpp') diff --git a/Minecraft.World/DispenserTile.cpp b/Minecraft.World/DispenserTile.cpp index 8758b3c5..5098fe30 100644 --- a/Minecraft.World/DispenserTile.cpp +++ b/Minecraft.World/DispenserTile.cpp @@ -18,9 +18,9 @@ DispenserTile::DispenserTile(int id) : BaseEntityTile(id, Material::stone) { random = new Random(); - iconTop = NULL; - iconFront = NULL; - iconFrontVertical = NULL; + iconTop = nullptr; + iconFront = nullptr; + iconFrontVertical = nullptr; } int DispenserTile::getTickDelay(Level *level) @@ -115,7 +115,7 @@ void DispenserTile::dispenseFrom(Level *level, int x, int y, int z) { BlockSourceImpl source(level, x, y, z); shared_ptr trap = dynamic_pointer_cast( source.getEntity() ); - if (trap == NULL) return; + if (trap == nullptr) return; int slot = trap->getRandomSlot(); if (slot < 0) @@ -168,7 +168,7 @@ void DispenserTile::tick(Level *level, int x, int y, int z, Random *random) shared_ptr DispenserTile::newTileEntity(Level *level) { - return shared_ptr( new DispenserTileEntity() ); + return std::make_shared(); } void DispenserTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr by, shared_ptr itemInstance) @@ -186,12 +186,12 @@ void DispenserTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr
  • container = dynamic_pointer_cast( level->getTileEntity(x, y, z) ); - if (container != NULL ) + if (container != nullptr ) { for (unsigned int i = 0; i < container->getContainerSize(); i++) { shared_ptr item = container->getItem(i); - if (item != NULL) + if (item != nullptr) { float xo = random->nextFloat() * 0.8f + 0.1f; float yo = random->nextFloat() * 0.8f + 0.1f; @@ -203,16 +203,16 @@ void DispenserTile::onRemove(Level *level, int x, int y, int z, int id, int data if (count > item->count) count = item->count; item->count -= count; - shared_ptr newItem = shared_ptr( new ItemInstance(item->id, count, item->getAuxValue()) ); + shared_ptr newItem = std::make_shared(item->id, count, item->getAuxValue()); newItem->set4JData( item->get4JData() ); - shared_ptr itemEntity = shared_ptr( new ItemEntity(level, x + xo, y + yo, z + zo, newItem ) ); + shared_ptr itemEntity = std::make_shared(level, x + xo, y + yo, z + zo, newItem); 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; if (item->hasTag()) { - itemEntity->getItem()->setTag((CompoundTag *) item->getTag()->copy()); + itemEntity->getItem()->setTag(static_cast(item->getTag()->copy())); } level->addEntity(itemEntity); } -- cgit v1.2.3