summaryrefslogtreecommitdiffstats
path: root/src/Blocks
diff options
context:
space:
mode:
Diffstat (limited to 'src/Blocks')
-rw-r--r--src/Blocks/BlockButton.h27
-rw-r--r--src/Blocks/BlockLever.h3
2 files changed, 26 insertions, 4 deletions
diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h
index f4994f193..9d8bf3da1 100644
--- a/src/Blocks/BlockButton.h
+++ b/src/Blocks/BlockButton.h
@@ -48,7 +48,7 @@ public:
const auto SoundToPlay = (m_BlockType == E_BLOCK_STONE_BUTTON) ? "block.stone_button.click_on" : "block.wood_button.click_on";
a_ChunkInterface.SetBlockMeta(a_BlockPos, Meta, false);
- a_WorldInterface.WakeUpSimulators(a_BlockPos);
+ WakeUpSimulators(a_WorldInterface, a_BlockPos);
a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect(SoundToPlay, a_BlockPos, 0.5f, 0.6f, a_Player.GetClientHandle());
// Queue a button reset (unpress)
@@ -186,7 +186,7 @@ public:
}
a_World.SetBlockMeta(Pos, Meta | 0x08, false);
- a_World.WakeUpSimulators(Pos);
+ WakeUpSimulators(a_World, Pos);
// sound name is ok to be wood, because only wood gets triggered by arrow
a_World.GetBroadcastManager().BroadcastSoundEffect("block.wood_button.click_on", Pos, 0.5f, 0.6f);
@@ -195,6 +195,27 @@ public:
QueueButtonRelease(a_World, Pos, Type);
}
+ /** Notify, mainly the redstone simulator, that this toggle component has updated. */
+ template <class WorldType>
+ static void WakeUpSimulators(WorldType & a_World, const Vector3i a_Position)
+ {
+ // Contains our direct adjacents
+ static const Vector3i Offsets[] =
+ {
+ { 1, 0, 0 },
+ { -1, 0, 0 },
+ { 0, 1, 0 },
+ { 0, -1, 0 },
+ { 0, 0, 1 },
+ { 0, 0, -1 }
+ };
+
+ for (const auto & Offset : Offsets)
+ {
+ a_World.WakeUpSimulators(a_Position + Offset);
+ }
+ }
+
private:
/** Schedules a recurring event at appropriate intervals to release a button at a given position.
@@ -229,7 +250,7 @@ private:
const auto SoundToPlayOnRelease = (Type == E_BLOCK_STONE_BUTTON) ? "block.stone_button.click_off" : "block.wood_button.click_off";
a_World.SetBlockMeta(a_Position, Meta & 0x07, false);
- a_World.WakeUpSimulators(a_Position);
+ WakeUpSimulators(a_World, a_Position);
a_World.BroadcastSoundEffect(SoundToPlayOnRelease, a_Position, 0.5f, 0.5f);
}
);
diff --git a/src/Blocks/BlockLever.h b/src/Blocks/BlockLever.h
index 4a682322d..7f028b61f 100644
--- a/src/Blocks/BlockLever.h
+++ b/src/Blocks/BlockLever.h
@@ -3,6 +3,7 @@
#include "BlockHandler.h"
#include "../Chunk.h"
#include "Mixins.h"
+#include "BlockButton.h"
#include "BlockSlab.h"
@@ -35,7 +36,7 @@ public:
NIBBLETYPE Meta = (a_ChunkInterface.GetBlockMeta(a_BlockPos) ^ 0x08);
a_ChunkInterface.SetBlockMeta(a_BlockPos, Meta);
- a_WorldInterface.WakeUpSimulators(a_BlockPos);
+ cBlockButtonHandler::WakeUpSimulators(a_WorldInterface, a_BlockPos);
a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("block.lever.click", a_BlockPos, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
return true;
}