summaryrefslogtreecommitdiffstats
path: root/src/Blocks
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-03-02 10:22:40 +0100
committerMattes D <github@xoft.cz>2014-03-02 10:22:40 +0100
commit0f2d9bc35f98ebe01fa83392f21ba18f63a68ad2 (patch)
tree3b5f0158e91c817336e124e34019cf479897e967 /src/Blocks
parentAdded more documentation for FastNBT parser. (diff)
parentUse switch in GetStepSound (diff)
downloadcuberite-0f2d9bc35f98ebe01fa83392f21ba18f63a68ad2.tar
cuberite-0f2d9bc35f98ebe01fa83392f21ba18f63a68ad2.tar.gz
cuberite-0f2d9bc35f98ebe01fa83392f21ba18f63a68ad2.tar.bz2
cuberite-0f2d9bc35f98ebe01fa83392f21ba18f63a68ad2.tar.lz
cuberite-0f2d9bc35f98ebe01fa83392f21ba18f63a68ad2.tar.xz
cuberite-0f2d9bc35f98ebe01fa83392f21ba18f63a68ad2.tar.zst
cuberite-0f2d9bc35f98ebe01fa83392f21ba18f63a68ad2.zip
Diffstat (limited to '')
-rw-r--r--src/Blocks/BlockSlab.h33
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 "";
}
} ;