From b3feddfef372618c8a9d7a0abcaf18cfad866c18 Mon Sep 17 00:00:00 2001 From: daoge <3523206925@qq.com> Date: Tue, 3 Mar 2026 03:04:10 +0800 Subject: 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 --- Minecraft.World/CommandBlock.cpp | 96 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 Minecraft.World/CommandBlock.cpp (limited to 'Minecraft.World/CommandBlock.cpp') diff --git a/Minecraft.World/CommandBlock.cpp b/Minecraft.World/CommandBlock.cpp new file mode 100644 index 00000000..e1b6b8dd --- /dev/null +++ b/Minecraft.World/CommandBlock.cpp @@ -0,0 +1,96 @@ +#include "stdafx.h" +#include "net.minecraft.world.level.h" +#include "net.minecraft.world.level.redstone.h" +#include "net.minecraft.world.level.tile.entity.h" +#include "CommandBlock.h" + +CommandBlock::CommandBlock(int id) : BaseEntityTile(id, Material::metal, isSolidRender() ) +{ +} + +shared_ptr CommandBlock::newTileEntity(Level *level) +{ + return shared_ptr( new CommandBlockEntity() ); +} + +void CommandBlock::neighborChanged(Level *level, int x, int y, int z, int type) +{ + if (!level->isClientSide) + { + + bool signal = level->hasNeighborSignal(x, y, z); + int data = level->getData(x, y, z); + bool isTriggered = (data & TRIGGER_BIT) != 0; + + if (signal && !isTriggered) + { + level->setData(x, y, z, data | TRIGGER_BIT, Tile::UPDATE_NONE); + level->addToTickNextTick(x, y, z, id, getTickDelay(level)); + } + else if (!signal && isTriggered) + { + level->setData(x, y, z, data & ~TRIGGER_BIT, Tile::UPDATE_NONE); + } + } +} + +void CommandBlock::tick(Level *level, int x, int y, int z, Random *random) +{ + shared_ptr tileEntity = level->getTileEntity(x, y, z); + + if (tileEntity != NULL && dynamic_pointer_cast( tileEntity ) != NULL) + { + shared_ptr commandBlock = dynamic_pointer_cast( tileEntity ); + commandBlock->setSuccessCount(commandBlock->performCommand(level)); + level->updateNeighbourForOutputSignal(x, y, z, id); + } +} + +int CommandBlock::getTickDelay(Level *level) +{ + return 1; +} + +bool CommandBlock::use(Level *level, int x, int y, int z, shared_ptr player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly) +{ + shared_ptr amce = dynamic_pointer_cast( level->getTileEntity(x, y, z) ); + + if (amce != NULL) + { + player->openTextEdit(amce); + } + + return true; +} + +bool CommandBlock::hasAnalogOutputSignal() +{ + return true; +} + +int CommandBlock::getAnalogOutputSignal(Level *level, int x, int y, int z, int dir) +{ + shared_ptr tileEntity = level->getTileEntity(x, y, z); + + if (tileEntity != NULL && dynamic_pointer_cast( tileEntity ) != NULL) + { + return dynamic_pointer_cast( tileEntity )->getSuccessCount(); + } + + return Redstone::SIGNAL_NONE; +} + +void CommandBlock::setPlacedBy(Level *level, int x, int y, int z, shared_ptr by, shared_ptr itemInstance) +{ + shared_ptr cblock = dynamic_pointer_cast( level->getTileEntity(x, y, z) ); + + if (itemInstance->hasCustomHoverName()) + { + cblock->setName(itemInstance->getHoverName()); + } +} + +int CommandBlock::getResourceCount(Random *random) +{ + return 0; +} \ No newline at end of file -- cgit v1.2.3