diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-03-09 13:53:50 +0100 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-03-09 13:53:50 +0100 |
commit | c2978a34576192d79c1fdc4664eafe316be49e51 (patch) | |
tree | 48db5c74ed757bfdf178a70e77eddff693c76a35 /src/Blocks/BlockSlab.h | |
parent | Hexified colours (diff) | |
parent | Updated Core (diff) | |
download | cuberite-c2978a34576192d79c1fdc4664eafe316be49e51.tar cuberite-c2978a34576192d79c1fdc4664eafe316be49e51.tar.gz cuberite-c2978a34576192d79c1fdc4664eafe316be49e51.tar.bz2 cuberite-c2978a34576192d79c1fdc4664eafe316be49e51.tar.lz cuberite-c2978a34576192d79c1fdc4664eafe316be49e51.tar.xz cuberite-c2978a34576192d79c1fdc4664eafe316be49e51.tar.zst cuberite-c2978a34576192d79c1fdc4664eafe316be49e51.zip |
Diffstat (limited to 'src/Blocks/BlockSlab.h')
-rw-r--r-- | src/Blocks/BlockSlab.h | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index 3628303ce..7cd2c97b2 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -28,7 +28,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - a_Pickups.push_back(cItem(m_BlockType, 1, a_BlockMeta)); + a_Pickups.push_back(cItem(m_BlockType, 1, a_BlockMeta & 0x7)); } @@ -41,7 +41,7 @@ public: { a_BlockType = m_BlockType; BLOCKTYPE Type = (BLOCKTYPE) (a_Player->GetEquippedItem().m_ItemType); - NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage & 0x07); + NIBBLETYPE Meta = (NIBBLETYPE) a_Player->GetEquippedItem().m_ItemDamage; // HandlePlaceBlock wants a cItemHandler pointer thing, so let's give it one cItemHandler * ItemHandler = cItemHandler::GetItemHandler(GetDoubleSlabType(Type)); @@ -159,21 +159,30 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - if (m_BlockType == E_BLOCK_DOUBLE_STONE_SLAB) - { - m_BlockType = E_BLOCK_STONE_SLAB; - } - else + BLOCKTYPE Block = GetSingleSlabType(m_BlockType); + a_Pickups.push_back(cItem(Block, 2, a_BlockMeta & 0x7)); + } + + inline static BLOCKTYPE GetSingleSlabType(BLOCKTYPE a_BlockType) + { + switch (a_BlockType) { - m_BlockType = 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; } - a_Pickups.push_back(cItem(m_BlockType, 2, a_BlockMeta)); + ASSERT(!"Unhandled double slab type!"); + return a_BlockType; } - virtual const char * GetStepSound(void) override - { - return ((m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB) || (m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB)) ? "step.wood" : "step.stone"; + { + switch (m_BlockType) + { + case E_BLOCK_DOUBLE_STONE_SLAB: return "step.stone"; + case E_BLOCK_DOUBLE_WOODEN_SLAB: return "step.wood"; + } + ASSERT(!"Unhandled double slab type!"); + return ""; } } ; |