summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockSlab.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Blocks/BlockSlab.h')
-rw-r--r--src/Blocks/BlockSlab.h73
1 files changed, 62 insertions, 11 deletions
diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h
index 46e0a8244..a136cd6e0 100644
--- a/src/Blocks/BlockSlab.h
+++ b/src/Blocks/BlockSlab.h
@@ -18,17 +18,29 @@
class cBlockSlabHandler :
public cBlockHandler
{
+ using super = cBlockHandler;
+
public:
- cBlockSlabHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
+
+ cBlockSlabHandler(BLOCKTYPE a_BlockType):
+ super(a_BlockType)
{
}
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+
+
+
+
+ virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) override
{
- a_Pickups.push_back(cItem(m_BlockType, 1, a_BlockMeta & 0x7));
+ // Reset the "top half" flag:
+ return cItem(m_BlockType, 1, a_BlockMeta & 0x07);
}
+
+
+
+
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer & a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@@ -84,6 +96,10 @@ public:
return true;
}
+
+
+
+
/** Returns true if the specified blocktype is one of the slabs handled by this handler */
static bool IsAnySlabType(BLOCKTYPE a_BlockType)
{
@@ -95,6 +111,10 @@ public:
);
}
+
+
+
+
virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override
{
if ((a_BlockFace == BLOCK_FACE_NONE) || (a_Player.GetEquippedItem().m_ItemType != static_cast<short>(m_BlockType)))
@@ -106,6 +126,10 @@ public:
a_Player.GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player);
}
+
+
+
+
/** Converts the single-slab blocktype to its equivalent double-slab blocktype */
static BLOCKTYPE GetDoubleSlabType(BLOCKTYPE a_SingleSlabBlockType)
{
@@ -120,12 +144,20 @@ public:
return E_BLOCK_AIR;
}
+
+
+
+
virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) override
{
// Toggle the 4th bit - up / down:
return (a_Meta ^ 0x08);
}
+
+
+
+
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
a_Meta &= 0x7;
@@ -184,6 +216,10 @@ public:
}
}
+
+
+
+
virtual bool IsInsideBlock(Vector3d a_Position, const BLOCKTYPE a_BlockType, const NIBBLETYPE a_BlockMeta) override
{
if (a_BlockMeta & 0x8) // top half
@@ -201,31 +237,46 @@ public:
class cBlockDoubleSlabHandler :
public cBlockHandler
{
+ using super = cBlockHandler;
+
public:
- cBlockDoubleSlabHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
+
+ cBlockDoubleSlabHandler(BLOCKTYPE a_BlockType):
+ super(a_BlockType)
{
}
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+
+
+
+
+ virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) override
{
BLOCKTYPE Block = GetSingleSlabType(m_BlockType);
- a_Pickups.push_back(cItem(Block, 2, a_BlockMeta & 0x7));
+ return cItem(Block, 2, a_BlockMeta & 0x7);
}
+
+
+
+
inline static BLOCKTYPE GetSingleSlabType(BLOCKTYPE a_BlockType)
{
switch (a_BlockType)
{
- case E_BLOCK_DOUBLE_STONE_SLAB: return E_BLOCK_STONE_SLAB;
- case E_BLOCK_DOUBLE_WOODEN_SLAB: return E_BLOCK_WOODEN_SLAB;
+ case E_BLOCK_DOUBLE_STONE_SLAB: return E_BLOCK_STONE_SLAB;
+ case E_BLOCK_DOUBLE_WOODEN_SLAB: return E_BLOCK_WOODEN_SLAB;
case E_BLOCK_DOUBLE_RED_SANDSTONE_SLAB: return E_BLOCK_RED_SANDSTONE_SLAB;
- case E_BLOCK_PURPUR_DOUBLE_SLAB: return E_BLOCK_PURPUR_SLAB;
+ case E_BLOCK_PURPUR_DOUBLE_SLAB: return E_BLOCK_PURPUR_SLAB;
}
ASSERT(!"Unhandled double slab type!");
return a_BlockType;
}
+
+
+
+
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
// For doule slabs, the meta values are the same. Only the meaning of the 4th bit changes, but that's ignored in the below handler