diff options
author | Bond-009 <bond.009@outlook.com> | 2017-11-20 12:13:11 +0100 |
---|---|---|
committer | Alexander Harkness <me@bearbin.net> | 2017-11-20 12:13:11 +0100 |
commit | 5badb9bccae803009bde182bf69ee0d02a36b22c (patch) | |
tree | 31fabd74fcee1138d4cacd0c437892c68c6defa9 /src/Blocks/BlockButton.h | |
parent | cItemHandler: Update max stack size of old doors. (#4072) (diff) | |
download | cuberite-5badb9bccae803009bde182bf69ee0d02a36b22c.tar cuberite-5badb9bccae803009bde182bf69ee0d02a36b22c.tar.gz cuberite-5badb9bccae803009bde182bf69ee0d02a36b22c.tar.bz2 cuberite-5badb9bccae803009bde182bf69ee0d02a36b22c.tar.lz cuberite-5badb9bccae803009bde182bf69ee0d02a36b22c.tar.xz cuberite-5badb9bccae803009bde182bf69ee0d02a36b22c.tar.zst cuberite-5badb9bccae803009bde182bf69ee0d02a36b22c.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Blocks/BlockButton.h | 21 |
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); } } ); |