From 221cc4ec5cb6301743e947eaabed3fecedba796f Mon Sep 17 00:00:00 2001 From: Mattes D Date: Wed, 16 Oct 2019 10:06:34 +0200 Subject: Refactored block-to-pickup conversion. (#4417) --- src/Blocks/BlockWallSign.h | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) (limited to 'src/Blocks/BlockWallSign.h') diff --git a/src/Blocks/BlockWallSign.h b/src/Blocks/BlockWallSign.h index 37ca2afae..3759b4db6 100644 --- a/src/Blocks/BlockWallSign.h +++ b/src/Blocks/BlockWallSign.h @@ -8,22 +8,31 @@ -class cBlockWallSignHandler : +class cBlockWallSignHandler: public cBlockHandler { - typedef cBlockHandler super; + using super = cBlockHandler; public: - cBlockWallSignHandler(BLOCKTYPE a_BlockType) : + + cBlockWallSignHandler(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(E_ITEM_SIGN, 1, 0)); + return cItem(E_ITEM_SIGN, 1, 0); } + + + + virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { int BlockX = (a_Chunk.GetPosX() * cChunkDef::Width) + a_RelX; @@ -34,6 +43,10 @@ public: return ((Type == E_BLOCK_WALLSIGN) || (Type == E_BLOCK_SIGN_POST) || cBlockInfo::IsSolid(Type)); } + + + + static void GetBlockCoordsBehindTheSign(NIBBLETYPE a_BlockMeta, int & a_BlockX, int & a_BlockZ) { switch (a_BlockMeta) @@ -46,14 +59,18 @@ public: } } + + + + static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction) { switch (a_Direction) { - case BLOCK_FACE_ZM: return 0x2; - case BLOCK_FACE_ZP: return 0x3; - case BLOCK_FACE_XM: return 0x4; - case BLOCK_FACE_XP: return 0x5; + case BLOCK_FACE_ZM: return 0x02; + case BLOCK_FACE_ZP: return 0x03; + case BLOCK_FACE_XM: return 0x04; + case BLOCK_FACE_XP: return 0x05; case BLOCK_FACE_NONE: case BLOCK_FACE_YP: case BLOCK_FACE_YM: @@ -61,9 +78,13 @@ public: break; } } - return 0x2; + return 0x02; } + + + + virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override { UNUSED(a_Meta); -- cgit v1.2.3