From 087b7e7abfe81dd7f0fdcdea36ac9f245950df1a Mon Sep 17 00:00:00 2001 From: Loki Rautio Date: Sat, 7 Mar 2026 21:12:22 -0600 Subject: Revert "Project modernization (#630)" This code was not tested and breaks in Release builds, reverting to restore functionality of the nightly. All in-game menus do not work and generating a world crashes. This reverts commit a9be52c41a02d207233199e98898fe7483d7e817. --- Minecraft.World/HopperTileEntity.cpp | 68 ++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'Minecraft.World/HopperTileEntity.cpp') diff --git a/Minecraft.World/HopperTileEntity.cpp b/Minecraft.World/HopperTileEntity.cpp index e44232dc..38a0e817 100644 --- a/Minecraft.World/HopperTileEntity.cpp +++ b/Minecraft.World/HopperTileEntity.cpp @@ -46,10 +46,10 @@ void HopperTileEntity::save(CompoundTag *base) for (int i = 0; i < items.length; i++) { - if (items[i] != nullptr) + if (items[i] != NULL) { CompoundTag *tag = new CompoundTag(); - tag->putByte(L"Slot", static_cast(i)); + tag->putByte(L"Slot", (byte) i); items[i]->save(tag); listTag->add(tag); } @@ -76,7 +76,7 @@ shared_ptr HopperTileEntity::getItem(unsigned int slot) shared_ptr HopperTileEntity::removeItem(unsigned int slot, int count) { - if (items[slot] != nullptr) + if (items[slot] != NULL) { if (items[slot]->count <= count) { @@ -96,7 +96,7 @@ shared_ptr HopperTileEntity::removeItem(unsigned int slot, int cou shared_ptr HopperTileEntity::removeItemNoUpdate(int slot) { - if (items[slot] != nullptr) + if (items[slot] != NULL) { shared_ptr item = items[slot]; items[slot] = nullptr; @@ -108,7 +108,7 @@ shared_ptr HopperTileEntity::removeItemNoUpdate(int slot) void HopperTileEntity::setItem(unsigned int slot, shared_ptr item) { items[slot] = item; - if (item != nullptr && item->count > getMaxStackSize()) item->count = getMaxStackSize(); + if (item != NULL && item->count > getMaxStackSize()) item->count = getMaxStackSize(); } wstring HopperTileEntity::getName() @@ -158,7 +158,7 @@ bool HopperTileEntity::canPlaceItem(int slot, shared_ptr item) void HopperTileEntity::tick() { - if (level == nullptr || level->isClientSide) return; + if (level == NULL || level->isClientSide) return; cooldownTime--; @@ -171,7 +171,7 @@ void HopperTileEntity::tick() bool HopperTileEntity::tryMoveItems() { - if (level == nullptr || level->isClientSide) return false; + if (level == NULL || level->isClientSide) return false; if (!isOnCooldown() && HopperTile::isTurnedOn(getData())) { @@ -192,19 +192,19 @@ bool HopperTileEntity::tryMoveItems() bool HopperTileEntity::ejectItems() { shared_ptr container = getAttachedContainer(); - if (container == nullptr) + if (container == NULL) { return false; } for (int slot = 0; slot < getContainerSize(); slot++) { - if (getItem(slot) == nullptr) continue; + if (getItem(slot) == NULL) continue; shared_ptr original = getItem(slot)->copy(); shared_ptr result = addItem(container.get(), removeItem(slot, 1), Facing::OPPOSITE_FACING[HopperTile::getAttachedFace(getData())]); - if (result == nullptr || result->count == 0) + if (result == NULL || result->count == 0) { container->setChanged(); return true; @@ -222,12 +222,12 @@ bool HopperTileEntity::suckInItems(Hopper *hopper) { shared_ptr container = getSourceContainer(hopper); - if (container != nullptr) + if (container != NULL) { int face = Facing::DOWN; shared_ptr worldly = dynamic_pointer_cast(container); - if ( (worldly != nullptr) && (face > -1) ) + if ( (worldly != NULL) && (face > -1) ) { intArray slots = worldly->getSlotsForFace(face); @@ -249,7 +249,7 @@ bool HopperTileEntity::suckInItems(Hopper *hopper) { shared_ptr above = getItemAt(hopper->getLevel(), hopper->getLevelX(), hopper->getLevelY() + 1, hopper->getLevelZ()); - if (above != nullptr) + if (above != NULL) { return addItem(hopper, above); } @@ -262,12 +262,12 @@ bool HopperTileEntity::tryTakeInItemFromSlot(Hopper *hopper, Container *containe { shared_ptr item = container->getItem(slot); - if (item != nullptr && canTakeItemFromContainer(container, item, slot, face)) + if (item != NULL && canTakeItemFromContainer(container, item, slot, face)) { shared_ptr original = item->copy(); shared_ptr result = addItem(hopper, container->removeItem(slot, 1), -1); - if (result == nullptr || result->count == 0) + if (result == NULL || result->count == 0) { container->setChanged(); return true; @@ -284,12 +284,12 @@ bool HopperTileEntity::tryTakeInItemFromSlot(Hopper *hopper, Container *containe bool HopperTileEntity::addItem(Container *container, shared_ptr item) { bool changed = false; - if (item == nullptr) return false; + if (item == NULL) return false; shared_ptr copy = item->getItem()->copy(); shared_ptr result = addItem(container, copy, -1); - if (result == nullptr || result->count == 0) + if (result == NULL || result->count == 0) { changed = true; @@ -305,12 +305,12 @@ bool HopperTileEntity::addItem(Container *container, shared_ptr item shared_ptr HopperTileEntity::addItem(Container *container, shared_ptr item, int face) { - if (dynamic_cast( container ) != nullptr && face > -1) + if (dynamic_cast( container ) != NULL && face > -1) { - WorldlyContainer *worldly = static_cast(container); + WorldlyContainer *worldly = (WorldlyContainer *) container; intArray slots = worldly->getSlotsForFace(face); - for (int i = 0; i < slots.length && item != nullptr && item->count > 0; i++) + for (int i = 0; i < slots.length && item != NULL && item->count > 0; i++) { item = tryMoveInItem(container, item, slots[i], face); } @@ -318,13 +318,13 @@ shared_ptr HopperTileEntity::addItem(Container *container, shared_ else { int size = container->getContainerSize(); - for (int i = 0; i < size && item != nullptr && item->count > 0; i++) + for (int i = 0; i < size && item != NULL && item->count > 0; i++) { item = tryMoveInItem(container, item, i, face); } } - if (item != nullptr && item->count == 0) + if (item != NULL && item->count == 0) { item = nullptr; } @@ -335,13 +335,13 @@ shared_ptr HopperTileEntity::addItem(Container *container, shared_ bool HopperTileEntity::canPlaceItemInContainer(Container *container, shared_ptr item, int slot, int face) { if (!container->canPlaceItem(slot, item)) return false; - if ( dynamic_cast( container ) != nullptr && !dynamic_cast( container )->canPlaceItemThroughFace(slot, item, face)) return false; + if ( dynamic_cast( container ) != NULL && !dynamic_cast( container )->canPlaceItemThroughFace(slot, item, face)) return false; return true; } bool HopperTileEntity::canTakeItemFromContainer(Container *container, shared_ptr item, int slot, int face) { - if (dynamic_cast( container ) != nullptr && !dynamic_cast( container )->canTakeItemThroughFace(slot, item, face)) return false; + if (dynamic_cast( container ) != NULL && !dynamic_cast( container )->canTakeItemThroughFace(slot, item, face)) return false; return true; } @@ -352,7 +352,7 @@ shared_ptr HopperTileEntity::tryMoveInItem(Container *container, s if (canPlaceItemInContainer(container, item, slot, face)) { bool success = false; - if (current == nullptr) + if (current == NULL) { container->setItem(slot, item); item = nullptr; @@ -370,7 +370,7 @@ shared_ptr HopperTileEntity::tryMoveInItem(Container *container, s if (success) { HopperTileEntity *hopper = dynamic_cast(container); - if (hopper != nullptr) + if (hopper != NULL) { hopper->setCooldown(MOVE_ITEM_SPEED); container->setChanged(); @@ -420,25 +420,25 @@ shared_ptr HopperTileEntity::getContainerAt(Level *level, double x, d shared_ptr entity = level->getTileEntity(xt, yt, zt); result = dynamic_pointer_cast(entity); - if (result != nullptr) + if (result != NULL) { - if ( dynamic_pointer_cast(result) != nullptr ) + if ( dynamic_pointer_cast(result) != NULL ) { int id = level->getTile(xt, yt, zt); Tile *tile = Tile::tiles[id]; - if ( dynamic_cast( tile ) != nullptr ) + if ( dynamic_cast( tile ) != NULL ) { - result = static_cast(tile)->getContainer(level, xt, yt, zt); + result = ((ChestTile *) tile)->getContainer(level, xt, yt, zt); } } } - if (result == nullptr) + if (result == NULL) { vector > *entities = level->getEntities(nullptr, AABB::newTemp(x, y, z, x + 1, y + 1, z + 1), EntitySelector::CONTAINER_ENTITY_SELECTOR); - if ( (entities != nullptr) && (entities->size() > 0) ) + if ( (entities != NULL) && (entities->size() > 0) ) { result = dynamic_pointer_cast( entities->at( level->random->nextInt(entities->size()) ) ); } @@ -489,14 +489,14 @@ bool HopperTileEntity::isOnCooldown() // 4J Added shared_ptr HopperTileEntity::clone() { - shared_ptr result = std::make_shared(); + shared_ptr result = shared_ptr( new HopperTileEntity() ); TileEntity::clone(result); result->name = name; result->cooldownTime = cooldownTime; for (unsigned int i = 0; i < items.length; i++) { - if (items[i] != nullptr) + if (items[i] != NULL) { result->items[i] = ItemInstance::clone(items[i]); } -- cgit v1.2.3