From 25ec7750aac9800bec83a844020a6eeda5cd4d74 Mon Sep 17 00:00:00 2001 From: Tycho Date: Fri, 31 Jan 2014 15:17:41 -0800 Subject: Changed signitures of Several BLockHandler Methods Changed the signitures of the following to use interfaces: GetPlacementBlockTypeMeta OnPlaced OnPlacedByPlayer OnDestroyed OnNeighbourChanged NeighbourChanged OnUse CanBeAt Check --- src/Blocks/BlockSlab.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Blocks/BlockSlab.h') diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index 7c1251b28..a1e73c94e 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -33,7 +33,7 @@ public: virtual bool GetPlacementBlockTypeMeta( - cWorld * a_World, cPlayer * a_Player, + cChunkInterface * a_ChunkInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta @@ -47,7 +47,7 @@ public: cItemHandler * ItemHandler = cItemHandler::GetItemHandler(GetDoubleSlabType(Type)); // Check if the block at the coordinates is a slab. Eligibility for combining has already been processed in ClientHandle - if (IsAnySlabType(a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ))) + if (IsAnySlabType(a_ChunkInterface->GetBlock(a_BlockX, a_BlockY, a_BlockZ))) { // Call the function in ClientHandle that places a block when the client sends the packet, // so that plugins may interfere with the placement. -- cgit v1.2.3 From c6304b2b4faf31c2e4a91a07bcac298467898dba Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 1 Feb 2014 05:06:32 -0800 Subject: Changed pointers to references --- src/Blocks/BlockSlab.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Blocks/BlockSlab.h') diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index a1e73c94e..51e78393a 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -33,7 +33,7 @@ public: virtual bool GetPlacementBlockTypeMeta( - cChunkInterface * a_ChunkInterface, cPlayer * a_Player, + cChunkInterface & a_ChunkInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta @@ -47,7 +47,7 @@ public: cItemHandler * ItemHandler = cItemHandler::GetItemHandler(GetDoubleSlabType(Type)); // Check if the block at the coordinates is a slab. Eligibility for combining has already been processed in ClientHandle - if (IsAnySlabType(a_ChunkInterface->GetBlock(a_BlockX, a_BlockY, a_BlockZ))) + if (IsAnySlabType(a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ))) { // Call the function in ClientHandle that places a block when the client sends the packet, // so that plugins may interfere with the placement. -- cgit v1.2.3 From 8464f689ea214d3c30105ae58539885cf1268317 Mon Sep 17 00:00:00 2001 From: Tycho Date: Tue, 4 Feb 2014 10:59:05 -0800 Subject: Improved Type safety of eBlockFace May Fix #640 --- src/Blocks/BlockSlab.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Blocks/BlockSlab.h') diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index 51e78393a..3628303ce 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -34,7 +34,7 @@ public: virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override -- cgit v1.2.3 From 66c84250410bf24bc689436c570c284bc47e3638 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 28 Feb 2014 15:26:32 +0100 Subject: Fix Double Slabs, fix Slab Meta and add more things to burnable --- src/Blocks/BlockSlab.h | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'src/Blocks/BlockSlab.h') diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index 3628303ce..8a3c998ec 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,32 @@ 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"; + { + BLOCKTYPE Block = GetSingleSlabType(m_BlockType); + if (Block != m_BlockType) + { + return cBlockHandler::GetBlockHandler(Block)->GetStepSound(); + } + else + { + return "step.stone"; + } } } ; -- cgit v1.2.3 From 0274db0e14adc269303380f41a54ffa07422317b Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 28 Feb 2014 22:32:10 +0100 Subject: Use switch in GetStepSound --- src/Blocks/BlockSlab.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/Blocks/BlockSlab.h') diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index 8a3c998ec..7cd2c97b2 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -176,15 +176,13 @@ public: virtual const char * GetStepSound(void) override { - BLOCKTYPE Block = GetSingleSlabType(m_BlockType); - if (Block != m_BlockType) - { - return cBlockHandler::GetBlockHandler(Block)->GetStepSound(); - } - else + switch (m_BlockType) { - return "step.stone"; + case E_BLOCK_DOUBLE_STONE_SLAB: return "step.stone"; + case E_BLOCK_DOUBLE_WOODEN_SLAB: return "step.wood"; } + ASSERT(!"Unhandled double slab type!"); + return ""; } } ; -- cgit v1.2.3 From 2343b0dfbe12f6db76de1b4ed03cd902975d77b3 Mon Sep 17 00:00:00 2001 From: narroo Date: Sun, 23 Mar 2014 22:11:01 -0400 Subject: Added MetaRotate/Mirror Support for a number of classes. --- src/Blocks/BlockSlab.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/Blocks/BlockSlab.h') diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index 7cd2c97b2..b18bf7ef3 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -14,8 +14,6 @@ - - class cBlockSlabHandler : public cBlockHandler { @@ -184,6 +182,15 @@ public: ASSERT(!"Unhandled double slab type!"); return ""; } + + + virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) override + { + NIBBLETYPE OtherMeta = a_Meta & 0x07; // Contains unrelate meta data. + + // 8th bit is up/down. 1 right-side-up, 0 is up-side-down. + return (a_Meta & 0x08) ? 0x00 + OtherMeta : 0x01 + OtherMeta; + } } ; -- cgit v1.2.3 From 90415ff79886f63cacced59f202228ddac69765a Mon Sep 17 00:00:00 2001 From: narroo Date: Wed, 26 Mar 2014 08:54:17 -0400 Subject: Fixed Minor typos. --- src/Blocks/BlockSlab.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Blocks/BlockSlab.h') diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index b18bf7ef3..77e8b8e55 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -186,7 +186,7 @@ public: virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) override { - NIBBLETYPE OtherMeta = a_Meta & 0x07; // Contains unrelate meta data. + NIBBLETYPE OtherMeta = a_Meta & 0x07; // Contains unrelated meta data. // 8th bit is up/down. 1 right-side-up, 0 is up-side-down. return (a_Meta & 0x08) ? 0x00 + OtherMeta : 0x01 + OtherMeta; -- cgit v1.2.3 From ee07b7ae3ec9cd283fe61aede067e7fc9e4bcb49 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 31 Mar 2014 20:34:11 +0100 Subject: Simplified and fixed slabs, fixes #835 --- src/Blocks/BlockSlab.h | 43 ++++++++++--------------------------------- 1 file changed, 10 insertions(+), 33 deletions(-) (limited to 'src/Blocks/BlockSlab.h') diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index 77e8b8e55..3f0fef0c7 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -11,6 +11,7 @@ #include "BlockHandler.h" #include "../Items/ItemHandler.h" +#include "Root.h" @@ -38,41 +39,9 @@ public: ) override { a_BlockType = m_BlockType; - BLOCKTYPE Type = (BLOCKTYPE) (a_Player->GetEquippedItem().m_ItemType); 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)); - - // Check if the block at the coordinates is a slab. Eligibility for combining has already been processed in ClientHandle - if (IsAnySlabType(a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ))) - { - // Call the function in ClientHandle that places a block when the client sends the packet, - // so that plugins may interfere with the placement. - - if ((a_BlockFace == BLOCK_FACE_TOP) || (a_BlockFace == BLOCK_FACE_BOTTOM)) - { - // Top and bottom faces need no parameter modification - a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); - } - else - { - // The other faces need to distinguish between top and bottom cursor positions - if (a_CursorY > 7) - { - // Edit the call to use BLOCK_FACE_BOTTOM, otherwise it places incorrectly - a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_TOP, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); - } - else - { - // Edit the call to use BLOCK_FACE_TOP, otherwise it places incorrectly - a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_BOTTOM, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); - } - } - return false; // Cancel the event, because dblslabs were already placed, nothing else needed - } - - // Place the single-slab with correct metas: + // Set the correct metadata based on player equipped item (i.e. a_BlockMeta not initialised yet) switch (a_BlockFace) { case BLOCK_FACE_TOP: @@ -104,6 +73,14 @@ public: } } } // switch (a_BlockFace) + + // Check if the block at the coordinates is a single slab. Eligibility for combining has already been processed in ClientHandle + // Changed to-be-placed to a double slab if we are clicking on a single slab, as opposed to placing one for the first time + if (IsAnySlabType(a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ))) + { + a_BlockType = GetDoubleSlabType(m_BlockType); + } + return true; } -- cgit v1.2.3 From 42e30b6513c8f905d419dd6621ad11959eea9dc9 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 1 Apr 2014 14:55:46 +0200 Subject: Fixed clang warnings in BlockHandlers. --- src/Blocks/BlockSlab.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Blocks/BlockSlab.h') diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index 77e8b8e55..4f94d45f6 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -103,6 +103,7 @@ public: a_BlockMeta = Meta & 0x7; break; } } + case BLOCK_FACE_NONE: return false; } // switch (a_BlockFace) return true; } -- cgit v1.2.3