1
0

Correct placement for tripwire hooks

487f9a2aa9 (r40900869)
This commit is contained in:
Tiger Wang 2020-07-25 20:29:55 +01:00
parent bc01cd5e75
commit b6e4a986b6

View File

@ -33,31 +33,37 @@ public:
) override ) override
{ {
a_BlockType = m_BlockType; a_BlockType = m_BlockType;
a_BlockMeta = DirectionToMetadata(a_ClickedBlockFace);
switch (a_ClickedBlockFace)
{
case BLOCK_FACE_XM:
{
a_BlockMeta = 0x1;
return true; return true;
} }
case BLOCK_FACE_XP:
inline static NIBBLETYPE DirectionToMetadata(eBlockFace a_Direction)
{ {
switch (a_Direction) a_BlockMeta = 0x3;
return true;
}
case BLOCK_FACE_ZM:
{ {
case BLOCK_FACE_XM: return 0x1; a_BlockMeta = 0x2;
case BLOCK_FACE_XP: return 0x3; return true;
case BLOCK_FACE_ZM: return 0x2; }
case BLOCK_FACE_ZP: return 0x0; case BLOCK_FACE_ZP:
{
a_BlockMeta = 0x0;
return true;
}
case BLOCK_FACE_NONE: case BLOCK_FACE_NONE:
case BLOCK_FACE_YM: case BLOCK_FACE_YM:
case BLOCK_FACE_YP: case BLOCK_FACE_YP:
{ {
ASSERT(!"Unhandled tripwire hook direction!"); return false;
return 0x0;
} }
} }
UNREACHABLE("Unsupported block face"); UNREACHABLE("Unsupported block face");
} }
@ -83,14 +89,15 @@ public:
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override
{ {
auto Meta = a_Chunk.GetMeta(a_RelPos); const auto Meta = a_Chunk.GetMeta(a_RelPos);
auto NeighborPos = AddFaceDirection(a_RelPos, MetadataToDirection(Meta), true); const auto RearPosition = AddFaceDirection(a_RelPos, MetadataToDirection(Meta), true);
if (!cChunkDef::IsValidHeight(NeighborPos.y))
BLOCKTYPE NeighborBlockType;
if (!a_Chunk.UnboundedRelGetBlockType(RearPosition, NeighborBlockType))
{ {
return false; return false;
} }
BLOCKTYPE NeighborBlockType;
a_Chunk.UnboundedRelGetBlockType(a_RelPos, NeighborBlockType);
return cBlockInfo::FullyOccupiesVoxel(NeighborBlockType); return cBlockInfo::FullyOccupiesVoxel(NeighborBlockType);
} }