diff options
Diffstat (limited to 'src/Blocks')
-rw-r--r-- | src/Blocks/BlockBed.cpp | 16 | ||||
-rw-r--r-- | src/Blocks/BlockIce.h | 2 | ||||
-rw-r--r-- | src/Blocks/BlockPiston.cpp | 7 |
3 files changed, 14 insertions, 11 deletions
diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp index e6193682a..8b349ef5e 100644 --- a/src/Blocks/BlockBed.cpp +++ b/src/Blocks/BlockBed.cpp @@ -21,27 +21,27 @@ void cBlockBedHandler::OnBroken(cChunkInterface & a_ChunkInterface, cWorldInterf if ((a_OldBlockMeta & 0x08) != 0) { // Was pillow - if (a_ChunkInterface.GetBlock(a_BlockPos - Direction) == E_BLOCK_BED) + Vector3i FootPos(a_BlockPos - Direction); + if (a_ChunkInterface.GetBlock(FootPos) == E_BLOCK_BED) { // First replace the bed with air - a_ChunkInterface.FastSetBlock(a_BlockPos - Direction, E_BLOCK_AIR, 0); + a_ChunkInterface.FastSetBlock(FootPos, E_BLOCK_AIR, 0); // Then destroy the bed entity - Vector3i PillowPos(a_BlockPos - Direction); - a_ChunkInterface.SetBlock(PillowPos, E_BLOCK_AIR, 0); + a_ChunkInterface.SetBlock(FootPos, E_BLOCK_AIR, 0); } } else { // Was foot end - if (a_ChunkInterface.GetBlock(a_BlockPos + Direction) == E_BLOCK_BED) + Vector3i PillowPos(a_BlockPos + Direction); + if (a_ChunkInterface.GetBlock(PillowPos) == E_BLOCK_BED) { // First replace the bed with air - a_ChunkInterface.FastSetBlock(a_BlockPos + Direction, E_BLOCK_AIR, 0); + a_ChunkInterface.FastSetBlock(PillowPos, E_BLOCK_AIR, 0); // Then destroy the bed entity - Vector3i FootPos(a_BlockPos + Direction); - a_ChunkInterface.SetBlock(FootPos, E_BLOCK_AIR, 0); + a_ChunkInterface.SetBlock(PillowPos, E_BLOCK_AIR, 0); } } } diff --git a/src/Blocks/BlockIce.h b/src/Blocks/BlockIce.h index 672288ca3..a39162d79 100644 --- a/src/Blocks/BlockIce.h +++ b/src/Blocks/BlockIce.h @@ -54,6 +54,8 @@ public: auto blockTypeBelow = a_ChunkInterface.GetBlock(a_BlockPos.addedY(-1)); if (cBlockInfo::FullyOccupiesVoxel(blockTypeBelow) || IsBlockLiquid(blockTypeBelow)) { + // Setting air with FastSetBlock prevents SetBlock recursively calling OnBroken. + a_ChunkInterface.FastSetBlock(a_BlockPos, E_BLOCK_AIR, 0); a_ChunkInterface.SetBlock(a_BlockPos, E_BLOCK_WATER, 0); } } diff --git a/src/Blocks/BlockPiston.cpp b/src/Blocks/BlockPiston.cpp index 5a18cffac..8c6940454 100644 --- a/src/Blocks/BlockPiston.cpp +++ b/src/Blocks/BlockPiston.cpp @@ -297,9 +297,10 @@ void cBlockPistonHandler::RetractPiston(Vector3i a_BlockPos, cWorld & a_World) return; } - // Remove extension, update base state - World.SetBlock(extensionPos.x, extensionPos.y, extensionPos.z, E_BLOCK_AIR, 0); - World.SetBlock(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, pistonBlock, pistonMeta & ~(8)); + // Remove extension, update base state. Calling FastSetBlock inhibits OnBroken being called by SetBlock. + World.FastSetBlock(extensionPos, E_BLOCK_AIR, 0); + World.SetBlock(extensionPos, E_BLOCK_AIR, 0); + World.SetBlock(a_BlockPos, pistonBlock, pistonMeta & ~(8)); // (Retraction is always successful, but play in the task for consistency) World.BroadcastSoundEffect("block.piston.contract", a_BlockPos, 0.5f, 0.7f); |