diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-09-02 09:45:06 +0200 |
---|---|---|
committer | Alexander Harkness <me@bearbin.net> | 2017-09-02 09:50:23 +0200 |
commit | 49c443896dcac8c4eaf08c4024e8bd2366ad899a (patch) | |
tree | b1ec46cab2b4e5731860c7136f1bbfca6fe9d458 /src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h | |
parent | SetSwimState now takes into account head height (diff) | |
download | cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.gz cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.bz2 cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.lz cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.xz cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.zst cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.zip |
Diffstat (limited to 'src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h')
-rw-r--r-- | src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h b/src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h index d280f73e3..8b7b82d49 100644 --- a/src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h +++ b/src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h @@ -1,4 +1,4 @@ - + #pragma once #include "RedstoneHandler.h" @@ -28,15 +28,38 @@ public: UNUSED(a_BlockType); UNUSED(a_Meta); - int NumberOfPlayers = 0; - VERIFY(!a_World.DoWithChestAt(a_Position.x, a_Position.y, a_Position.z, [&](cChestEntity & a_Chest) + class cGetTrappedChestPlayers : + public cItemCallback<cChestEntity> + { + public: + cGetTrappedChestPlayers(void) : + m_NumberOfPlayers(0) + { + } + + virtual ~cGetTrappedChestPlayers() override + { + } + + virtual bool Item(cChestEntity * a_Chest) override { - ASSERT(a_Chest.GetBlockType() == E_BLOCK_TRAPPED_CHEST); - NumberOfPlayers = a_Chest.GetNumberOfPlayers(); + ASSERT(a_Chest->GetBlockType() == E_BLOCK_TRAPPED_CHEST); + m_NumberOfPlayers = a_Chest->GetNumberOfPlayers(); return true; } - )); - return static_cast<unsigned char>(std::min(NumberOfPlayers, 15)); + + unsigned char GetPowerLevel(void) const + { + return static_cast<unsigned char>(std::min(m_NumberOfPlayers, 15)); + } + + private: + int m_NumberOfPlayers; + + } GTCP; + + VERIFY(!a_World.DoWithChestAt(a_Position.x, a_Position.y, a_Position.z, GTCP)); + return GTCP.GetPowerLevel(); } virtual cVector3iArray Update(cWorld & a_World, const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override |