summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockTripwireHook.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-07-25 21:29:55 +0200
committerTiger Wang <ziwei.tiger@outlook.com>2020-07-25 21:29:55 +0200
commitb6e4a986b6d6cb2923e33bc81882e52875223d41 (patch)
tree378c9e3263e731fefc2f142aa0dd2d683447c180 /src/Blocks/BlockTripwireHook.h
parentRedstone: check validity of GetBlock (diff)
downloadcuberite-b6e4a986b6d6cb2923e33bc81882e52875223d41.tar
cuberite-b6e4a986b6d6cb2923e33bc81882e52875223d41.tar.gz
cuberite-b6e4a986b6d6cb2923e33bc81882e52875223d41.tar.bz2
cuberite-b6e4a986b6d6cb2923e33bc81882e52875223d41.tar.lz
cuberite-b6e4a986b6d6cb2923e33bc81882e52875223d41.tar.xz
cuberite-b6e4a986b6d6cb2923e33bc81882e52875223d41.tar.zst
cuberite-b6e4a986b6d6cb2923e33bc81882e52875223d41.zip
Diffstat (limited to 'src/Blocks/BlockTripwireHook.h')
-rw-r--r--src/Blocks/BlockTripwireHook.h51
1 files changed, 29 insertions, 22 deletions
diff --git a/src/Blocks/BlockTripwireHook.h b/src/Blocks/BlockTripwireHook.h
index 766c0e404..f28b94b46 100644
--- a/src/Blocks/BlockTripwireHook.h
+++ b/src/Blocks/BlockTripwireHook.h
@@ -33,31 +33,37 @@ public:
) override
{
a_BlockType = m_BlockType;
- a_BlockMeta = DirectionToMetadata(a_ClickedBlockFace);
- return true;
- }
-
-
-
-
-
- inline static NIBBLETYPE DirectionToMetadata(eBlockFace a_Direction)
- {
- switch (a_Direction)
+ switch (a_ClickedBlockFace)
{
- case BLOCK_FACE_XM: return 0x1;
- case BLOCK_FACE_XP: return 0x3;
- case BLOCK_FACE_ZM: return 0x2;
- case BLOCK_FACE_ZP: return 0x0;
+ case BLOCK_FACE_XM:
+ {
+ a_BlockMeta = 0x1;
+ return true;
+ }
+ case BLOCK_FACE_XP:
+ {
+ a_BlockMeta = 0x3;
+ return true;
+ }
+ case BLOCK_FACE_ZM:
+ {
+ a_BlockMeta = 0x2;
+ return true;
+ }
+ case BLOCK_FACE_ZP:
+ {
+ a_BlockMeta = 0x0;
+ return true;
+ }
case BLOCK_FACE_NONE:
case BLOCK_FACE_YM:
case BLOCK_FACE_YP:
{
- ASSERT(!"Unhandled tripwire hook direction!");
- return 0x0;
+ return false;
}
}
+
UNREACHABLE("Unsupported block face");
}
@@ -83,14 +89,15 @@ public:
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
{
- auto Meta = a_Chunk.GetMeta(a_RelPos);
- auto NeighborPos = AddFaceDirection(a_RelPos, MetadataToDirection(Meta), true);
- if (!cChunkDef::IsValidHeight(NeighborPos.y))
+ const auto Meta = a_Chunk.GetMeta(a_RelPos);
+ const auto RearPosition = AddFaceDirection(a_RelPos, MetadataToDirection(Meta), true);
+
+ BLOCKTYPE NeighborBlockType;
+ if (!a_Chunk.UnboundedRelGetBlockType(RearPosition, NeighborBlockType))
{
return false;
}
- BLOCKTYPE NeighborBlockType;
- a_Chunk.UnboundedRelGetBlockType(a_RelPos, NeighborBlockType);
+
return cBlockInfo::FullyOccupiesVoxel(NeighborBlockType);
}