diff options
| author | daoge <3523206925@qq.com> | 2026-03-03 03:04:10 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-03 03:04:10 +0800 |
| commit | b3feddfef372618c8a9d7a0abcaf18cfad866c18 (patch) | |
| tree | 267761c3bb39241ba5c347bfbe2254d06686e287 /Minecraft.World/DropperTile.cpp | |
| parent | 84c31a2331f7a0ec85b9d438992e244f60e5020f (diff) | |
feat: TU19 (Dec 2014) Features & Content (#155)
* try to resolve merge conflict
* feat: TU19 (Dec 2014) Features & Content (#32)
* December 2014 files
* Working release build
* Fix compilation issues
* Add sound to Windows64Media
* Add DLC content and force Tutorial DLC
* Revert "Add DLC content and force Tutorial DLC"
This reverts commit 97a43994725008e35fceb984d5549df9c8cea470.
* Disable broken light packing
* Disable breakpoint during DLC texture map load
Allows DLC loading but the DLC textures are still broken
* Fix post build not working
* ...
* fix vs2022 build
* fix cmake build
---------
Co-authored-by: Loki <lokirautio@gmail.com>
Diffstat (limited to 'Minecraft.World/DropperTile.cpp')
| -rw-r--r-- | Minecraft.World/DropperTile.cpp | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/Minecraft.World/DropperTile.cpp b/Minecraft.World/DropperTile.cpp new file mode 100644 index 00000000..a28228c9 --- /dev/null +++ b/Minecraft.World/DropperTile.cpp @@ -0,0 +1,74 @@ +#include "stdafx.h" +#include "net.minecraft.world.level.h" +#include "net.minecraft.world.level.tile.h" +#include "net.minecraft.world.level.tile.entity.h" +#include "net.minecraft.h" +#include "net.minecraft.world.h" +#include "net.minecraft.core.h" +#include "DropperTile.h" + +DropperTile::DropperTile(int id) : DispenserTile(id) +{ + DISPENSE_BEHAVIOUR = new DefaultDispenseItemBehavior(); +} + +void DropperTile::registerIcons(IconRegister *iconRegister) +{ + icon = iconRegister->registerIcon(L"furnace_side"); + iconTop = iconRegister->registerIcon(L"furnace_top"); + iconFront = iconRegister->registerIcon(getIconName() + L"_front_horizontal"); + iconFrontVertical = iconRegister->registerIcon(getIconName() + L"_front_vertical"); +} + +DispenseItemBehavior *DropperTile::getDispenseMethod(shared_ptr<ItemInstance> item) +{ + return DISPENSE_BEHAVIOUR; +} + +shared_ptr<TileEntity> DropperTile::newTileEntity(Level *level) +{ + return shared_ptr<DropperTileEntity>( new DropperTileEntity() ); +} + +void DropperTile::dispenseFrom(Level *level, int x, int y, int z) +{ + BlockSourceImpl source(level, x, y, z); + shared_ptr<DispenserTileEntity> trap = dynamic_pointer_cast<DispenserTileEntity>( source.getEntity() ); + if (trap == NULL) return; + + int slot = trap->getRandomSlot(); + if (slot < 0) + { + level->levelEvent(LevelEvent::SOUND_CLICK_FAIL, x, y, z, 0); + } + else + { + shared_ptr<ItemInstance> item = trap->getItem(slot); + int face = level->getData(x, y, z) & DispenserTile::FACING_MASK; + shared_ptr<Container> into = HopperTileEntity::getContainerAt(level, x + Facing::STEP_X[face], y + Facing::STEP_Y[face], z + Facing::STEP_Z[face]); + shared_ptr<ItemInstance> remaining = nullptr; + + if (into != NULL) + { + remaining = HopperTileEntity::addItem(into.get(), item->copy()->remove(1), Facing::OPPOSITE_FACING[face]); + + if (remaining == NULL) + { + remaining = item->copy(); + if (--remaining->count == 0) remaining = nullptr; + } + else + { + // placing one item failed, so restore original count + remaining = item->copy(); + } + } + else + { + remaining = DISPENSE_BEHAVIOUR->dispense(&source, item); + if (remaining != NULL && remaining->count == 0) remaining = nullptr; + } + + trap->setItem(slot, remaining); + } +}
\ No newline at end of file |
