summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockButton.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Blocks/BlockButton.h')
-rw-r--r--src/Blocks/BlockButton.h21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h
index 079f461ab..2b646c6e8 100644
--- a/src/Blocks/BlockButton.h
+++ b/src/Blocks/BlockButton.h
@@ -18,11 +18,10 @@ public:
virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
{
- NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ Vector3i Pos(a_BlockX, a_BlockY, a_BlockZ);
+ NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(Pos);
- double x(a_BlockX);
- double y(a_BlockY);
- double z(a_BlockZ);
+ Vector3d SoundPos(Pos);
// If button is already on do nothing
if (Meta & 0x08)
@@ -34,19 +33,19 @@ public:
Meta |= 0x08;
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta, false);
- a_WorldInterface.WakeUpSimulators({a_BlockX, a_BlockY, a_BlockZ});
- a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("block.stone_button.click_on", {x, y, z}, 0.5f, 0.6f);
+ a_WorldInterface.WakeUpSimulators(Pos);
+ a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("block.stone_button.click_on", SoundPos, 0.5f, 0.6f);
// Queue a button reset (unpress)
auto TickDelay = (m_BlockType == E_BLOCK_STONE_BUTTON) ? 20 : 30;
- a_Player.GetWorld()->ScheduleTask(TickDelay, [x, y, z, a_BlockX, a_BlockY, a_BlockZ, this](cWorld & a_World)
+ a_Player.GetWorld()->ScheduleTask(TickDelay, [SoundPos, Pos, this](cWorld & a_World)
{
- if (a_World.GetBlock(a_BlockX, a_BlockY, a_BlockZ) == m_BlockType)
+ if (a_World.GetBlock(Pos) == m_BlockType)
{
// Block hasn't change in the meantime; set its meta
- a_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, a_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) & 0x07, false);
- a_World.WakeUpSimulators({a_BlockX, a_BlockY, a_BlockZ});
- a_World.BroadcastSoundEffect("block.stone_button.click_off", {x, y, z}, 0.5f, 0.5f);
+ a_World.SetBlockMeta(Pos.x, Pos.y, Pos.z, a_World.GetBlockMeta(Pos) & 0x07, false);
+ a_World.WakeUpSimulators(Pos);
+ a_World.BroadcastSoundEffect("block.stone_button.click_off", SoundPos, 0.5f, 0.5f);
}
}
);