diff options
Diffstat (limited to 'source/Blocks/BlockSlab.h')
-rw-r--r-- | source/Blocks/BlockSlab.h | 58 |
1 files changed, 48 insertions, 10 deletions
diff --git a/source/Blocks/BlockSlab.h b/source/Blocks/BlockSlab.h index 44e1962b9..881a85615 100644 --- a/source/Blocks/BlockSlab.h +++ b/source/Blocks/BlockSlab.h @@ -6,7 +6,6 @@ - class cBlockSlabHandler : public cBlockHandler { @@ -19,7 +18,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - char Count = ((m_BlockType == E_BLOCK_DOUBLE_STONE_SLAB) || (m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB)) ? 2 : 1; + char Count = ((m_BlockType == E_BLOCK_STONE_SLAB) || (m_BlockType == E_BLOCK_WOODEN_SLAB)) ? 1 : 1; a_Pickups.push_back(cItem(m_BlockType, Count, a_BlockMeta)); } @@ -32,22 +31,46 @@ public: ) override { a_BlockType = m_BlockType; + BLOCKTYPE Type = (BLOCKTYPE)(a_Player->GetEquippedItem().m_ItemType); NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage & 0x07); + + int DoubleType; + if (Type == E_BLOCK_STONE_SLAB) + { + DoubleType = 43; //Make it a double slab (with old type wood) + } + else + { + DoubleType = 125; //Make it a wooden double slab (new type) + } + cItemHandler * ItemHandler = cItemHandler::GetItemHandler(DoubleType); + switch (a_BlockFace) { case BLOCK_FACE_TOP: { - if (a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ) == E_BLOCK_STONE_SLAB) + if ((a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_STONE_SLAB) || (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_SLAB)) { - a_World->FastSetBlock(a_BlockX, a_BlockY - 1, a_BlockZ, E_BLOCK_DOUBLE_STONE_SLAB, Meta); //Set it to a slabby block - a_BlockType = E_BLOCK_AIR; //Stop the server trying to place another slab on top + a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); + return false; } else { a_BlockMeta = Meta & 0x7; break; //Bottom half if on top of non slab block } } - case BLOCK_FACE_BOTTOM: a_BlockMeta = Meta | 0x8; break; //Always top when placing on bottom of something + case BLOCK_FACE_BOTTOM: + { + if ((a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_STONE_SLAB) || (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_SLAB)) + { + a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); + return false; + } + else + { + a_BlockMeta = Meta | 0x8; break; //Bottom half if on top of non slab block + } + } case BLOCK_FACE_EAST: case BLOCK_FACE_NORTH: case BLOCK_FACE_SOUTH: @@ -56,14 +79,29 @@ public: if (a_CursorY > 7) { // Cursor at the top half of the face, place a top half of slab - a_BlockMeta = Meta | 0x8; + if ((a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_STONE_SLAB) || (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_SLAB)) + { + a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); + return false; + } + else + { + a_BlockMeta = Meta | 0x8; break; + } } else { // Cursor at the bottom half of the face, place a bottom half of slab: - a_BlockMeta = Meta & 0x7; + if ((a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_STONE_SLAB) || (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_SLAB)) + { + a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); + return false; + } + else + { + a_BlockMeta = Meta & 0x7; break; + } } - break; } } // switch (a_BlockFace) return true; @@ -72,7 +110,7 @@ public: virtual const char * GetStepSound(void) override { - return ((m_BlockType == E_BLOCK_WOODEN_SLAB) || (m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB)) ? "step.wood" : "step.stone"; + return ((m_BlockType == E_BLOCK_WOODEN_SLAB) || (m_BlockType == E_BLOCK_STONE_SLAB)) ? "step.wood" : "step.stone"; } } ; |