diff options
Diffstat (limited to '')
-rw-r--r-- | src/Blocks/BlockDoor.h | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h index 92ad8da12..74e608da8 100644 --- a/src/Blocks/BlockDoor.h +++ b/src/Blocks/BlockDoor.h @@ -117,7 +117,28 @@ public: virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { - return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR)); + if (a_Chunk.GetBlock(a_RelX, a_RelY, a_RelZ) != m_BlockType) + { + // In placing + return (cBlockInfo::FullyOccupiesVoxel(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ))); + } + + if ((a_RelY <= 0) || (a_RelY >= cChunkDef::Height)) + { + return false; + } + + NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ); + if ((Meta & 0x08) != 0) + { + // The coords are pointing at the top part of the door + return (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) == m_BlockType); + } + else + { + // The coords are pointing at the bottom part of the door + return cBlockInfo::FullyOccupiesVoxel(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)); + } } |