summaryrefslogtreecommitdiffstats
path: root/src/Simulator
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2013-11-29 23:27:08 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2013-11-29 23:27:08 +0100
commit1d69c80ad38b494f737bde455225259192093c15 (patch)
treeb9e3e8b04ae9da86369998ed5589113ee0589839 /src/Simulator
parentRemoved unneeded CPP files (diff)
downloadcuberite-1d69c80ad38b494f737bde455225259192093c15.tar
cuberite-1d69c80ad38b494f737bde455225259192093c15.tar.gz
cuberite-1d69c80ad38b494f737bde455225259192093c15.tar.bz2
cuberite-1d69c80ad38b494f737bde455225259192093c15.tar.lz
cuberite-1d69c80ad38b494f737bde455225259192093c15.tar.xz
cuberite-1d69c80ad38b494f737bde455225259192093c15.tar.zst
cuberite-1d69c80ad38b494f737bde455225259192093c15.zip
Diffstat (limited to '')
-rw-r--r--src/Simulator/RedstoneSimulator.cpp17
-rw-r--r--src/Simulator/RedstoneSimulator.h2
2 files changed, 19 insertions, 0 deletions
diff --git a/src/Simulator/RedstoneSimulator.cpp b/src/Simulator/RedstoneSimulator.cpp
index 81d4e26f6..ff6005acf 100644
--- a/src/Simulator/RedstoneSimulator.cpp
+++ b/src/Simulator/RedstoneSimulator.cpp
@@ -169,6 +169,7 @@ void cRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, c
case E_BLOCK_BLOCK_OF_REDSTONE: HandleRedstoneBlock(a_X, dataitr->y, a_Z); break;
case E_BLOCK_LEVER: HandleRedstoneLever(a_X, dataitr->y, a_Z); break;
case E_BLOCK_TNT: HandleTNT(a_X, dataitr->y, a_Z); break;
+ case E_BLOCK_TRAPDOOR: HandleTrapdoor(a_X, dataitr->y, a_Z); break;
case E_BLOCK_REDSTONE_WIRE: HandleRedstoneWire(a_X, dataitr->y, a_Z); break;
case E_BLOCK_REDSTONE_TORCH_OFF:
@@ -717,6 +718,22 @@ void cRedstoneSimulator::HandleRail(int a_BlockX, int a_BlockY, int a_BlockZ, BL
+void cRedstoneSimulator::HandleTrapdoor(int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ if (AreCoordsPowered(a_BlockX, a_BlockY, a_BlockZ))
+ {
+ m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) | 0x4);
+ }
+ else
+ {
+ m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) & 0xB); // Take into account that the fourth bit is needed for trapdoors too
+ }
+}
+
+
+
+
+
bool cRedstoneSimulator::AreCoordsPowered(int a_BlockX, int a_BlockY, int a_BlockZ)
{
for (PoweredBlocksList::iterator itr = m_PoweredBlocks.begin(); itr != m_PoweredBlocks.end(); ++itr) // Check powered list
diff --git a/src/Simulator/RedstoneSimulator.h b/src/Simulator/RedstoneSimulator.h
index d3002394a..9e244d7da 100644
--- a/src/Simulator/RedstoneSimulator.h
+++ b/src/Simulator/RedstoneSimulator.h
@@ -93,6 +93,8 @@ private:
void HandleDoor(int a_BlockX, int a_BlockY, int a_BlockZ);
/// <summary>Handles activator, detector, and powered rails</summary>
void HandleRail(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_MyType);
+ /// <summary>Handles trapdoors</summary>
+ void HandleTrapdoor(int a_BlockX, int a_BlockY, int a_BlockZ);
/* ===================== */
/* ====== Helper functions ====== */