summaryrefslogtreecommitdiffstats
path: root/src/Blocks
diff options
context:
space:
mode:
authorAlexander Harkness <me@bearbin.net>2020-04-03 22:24:49 +0200
committerGitHub <noreply@github.com>2020-04-03 22:24:49 +0200
commitba048e2101d42af53f2ac7a9a3ed04c194918136 (patch)
tree169c0e1f5f0cd306feadc00fd82b3079babf3088 /src/Blocks
parentQuick fix to make spawn eggs work (#4611) (diff)
downloadcuberite-ba048e2101d42af53f2ac7a9a3ed04c194918136.tar
cuberite-ba048e2101d42af53f2ac7a9a3ed04c194918136.tar.gz
cuberite-ba048e2101d42af53f2ac7a9a3ed04c194918136.tar.bz2
cuberite-ba048e2101d42af53f2ac7a9a3ed04c194918136.tar.lz
cuberite-ba048e2101d42af53f2ac7a9a3ed04c194918136.tar.xz
cuberite-ba048e2101d42af53f2ac7a9a3ed04c194918136.tar.zst
cuberite-ba048e2101d42af53f2ac7a9a3ed04c194918136.zip
Diffstat (limited to '')
-rw-r--r--src/Blocks/BlockBed.cpp16
-rw-r--r--src/Blocks/BlockIce.h2
-rw-r--r--src/Blocks/BlockPiston.cpp7
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);