diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2021-03-28 15:40:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-28 15:40:57 +0200 |
commit | 748b121703fa28b10933f4432c09391e66179118 (patch) | |
tree | 58a39b6a75c3e9127507bf3c185a99e546147276 /src/Simulator/IncrementalRedstoneSimulator | |
parent | Fix Windows XP to 7 compatibility (#5167) (diff) | |
download | cuberite-748b121703fa28b10933f4432c09391e66179118.tar cuberite-748b121703fa28b10933f4432c09391e66179118.tar.gz cuberite-748b121703fa28b10933f4432c09391e66179118.tar.bz2 cuberite-748b121703fa28b10933f4432c09391e66179118.tar.lz cuberite-748b121703fa28b10933f4432c09391e66179118.tar.xz cuberite-748b121703fa28b10933f4432c09391e66179118.tar.zst cuberite-748b121703fa28b10933f4432c09391e66179118.zip |
Diffstat (limited to 'src/Simulator/IncrementalRedstoneSimulator')
7 files changed, 39 insertions, 15 deletions
diff --git a/src/Simulator/IncrementalRedstoneSimulator/CommandBlockHandler.h b/src/Simulator/IncrementalRedstoneSimulator/CommandBlockHandler.h index c216d12bc..0a5ffe136 100644 --- a/src/Simulator/IncrementalRedstoneSimulator/CommandBlockHandler.h +++ b/src/Simulator/IncrementalRedstoneSimulator/CommandBlockHandler.h @@ -31,9 +31,14 @@ namespace CommandBlockHandler return; } - a_Chunk.DoWithCommandBlockAt(a_Position, [](cCommandBlockEntity & a_CommandBlock) + a_Chunk.DoWithBlockEntityAt(a_Position, [](cBlockEntity & a_BlockEntity) { - a_CommandBlock.Activate(); + if (a_BlockEntity.GetBlockType() != E_BLOCK_COMMAND_BLOCK) + { + return false; + } + + static_cast<cCommandBlockEntity &>(a_BlockEntity).Activate(); return false; }); } diff --git a/src/Simulator/IncrementalRedstoneSimulator/DropSpenserHandler.h b/src/Simulator/IncrementalRedstoneSimulator/DropSpenserHandler.h index 309fa757a..4dd87e972 100644 --- a/src/Simulator/IncrementalRedstoneSimulator/DropSpenserHandler.h +++ b/src/Simulator/IncrementalRedstoneSimulator/DropSpenserHandler.h @@ -46,9 +46,14 @@ namespace DropSpenserHandler if (IsPoweredNow && !WasPoweredPreviously) { - a_Chunk.DoWithDropSpenserAt(a_Position, [](cDropSpenserEntity & a_DropSpenser) + a_Chunk.DoWithBlockEntityAt(a_Position, [](cBlockEntity & a_BlockEntity) { - a_DropSpenser.Activate(); + if ((a_BlockEntity.GetBlockType() != E_BLOCK_DISPENSER) && (a_BlockEntity.GetBlockType() != E_BLOCK_DROPPER)) + { + return false; + } + + static_cast<cDropSpenserEntity &>(a_BlockEntity).Activate(); return false; }); } diff --git a/src/Simulator/IncrementalRedstoneSimulator/HopperHandler.h b/src/Simulator/IncrementalRedstoneSimulator/HopperHandler.h index 998a98677..379f7c7d8 100644 --- a/src/Simulator/IncrementalRedstoneSimulator/HopperHandler.h +++ b/src/Simulator/IncrementalRedstoneSimulator/HopperHandler.h @@ -30,9 +30,14 @@ namespace HopperHandler return; } - a_Chunk.DoWithHopperAt(a_Position, [Power](cHopperEntity & a_Hopper) + a_Chunk.DoWithBlockEntityAt(a_Position, [Power](cBlockEntity & a_BlockEntity) { - a_Hopper.SetLocked(Power != 0); + if (a_BlockEntity.GetBlockType() != E_BLOCK_HOPPER) + { + return false; + } + + static_cast<cHopperEntity &>(a_BlockEntity).SetLocked(Power != 0); return false; }); } diff --git a/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.h index e8cd4bf5d..b13d1f6f5 100644 --- a/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.h +++ b/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.h @@ -1,6 +1,7 @@ #pragma once +#include "BlockType.h" #include "../RedstoneSimulator.h" #include "RedstoneSimulatorChunkData.h" diff --git a/src/Simulator/IncrementalRedstoneSimulator/NoteBlockHandler.h b/src/Simulator/IncrementalRedstoneSimulator/NoteBlockHandler.h index 6a2f66737..8bd639357 100644 --- a/src/Simulator/IncrementalRedstoneSimulator/NoteBlockHandler.h +++ b/src/Simulator/IncrementalRedstoneSimulator/NoteBlockHandler.h @@ -31,9 +31,14 @@ namespace NoteBlockHandler return; } - a_Chunk.DoWithNoteBlockAt(a_Position, [](cNoteEntity & a_NoteBlock) + a_Chunk.DoWithBlockEntityAt(a_Position, [](cBlockEntity & a_BlockEntity) { - a_NoteBlock.MakeSound(); + if (a_BlockEntity.GetBlockType() != E_BLOCK_NOTE_BLOCK) + { + return false; + } + + static_cast<cNoteEntity &>(a_BlockEntity).MakeSound(); return false; }); } diff --git a/src/Simulator/IncrementalRedstoneSimulator/RedstoneHandler.cpp b/src/Simulator/IncrementalRedstoneSimulator/RedstoneHandler.cpp index 63da4c0dc..ab6b35c0b 100644 --- a/src/Simulator/IncrementalRedstoneSimulator/RedstoneHandler.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator/RedstoneHandler.cpp @@ -5,6 +5,7 @@ #include "RedstoneDataHelper.h" #include "ForEachSourceCallback.h" +#include "BlockType.h" #include "CommandBlockHandler.h" #include "DaylightSensorHandler.h" #include "DoorHandler.h" diff --git a/src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h b/src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h index 619401d80..145c5dc83 100644 --- a/src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h +++ b/src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h @@ -22,14 +22,16 @@ namespace TrappedChestHandler static unsigned char GetPowerLevel(cChunk & a_Chunk, Vector3i a_Position) { int NumberOfPlayers = 0; - VERIFY( - !a_Chunk.DoWithChestAt(a_Position, [&](cChestEntity & a_Chest) + a_Chunk.DoWithBlockEntityAt(a_Position, [&NumberOfPlayers](cBlockEntity & a_BlockEntity) + { + if (a_BlockEntity.GetBlockType() != E_BLOCK_TRAPPED_CHEST) { - ASSERT(a_Chest.GetBlockType() == E_BLOCK_TRAPPED_CHEST); - NumberOfPlayers = a_Chest.GetNumberOfPlayers(); - return true; - }) - ); + return false; + } + + NumberOfPlayers = static_cast<cChestEntity &>(a_BlockEntity).GetNumberOfPlayers(); + return false; + }); return static_cast<unsigned char>(std::min(NumberOfPlayers, 15)); } |