From 487f9a2aa9b5497495cef1ac3b9c7a603e69f862 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Tue, 21 Apr 2020 22:19:22 +0200 Subject: Vector3 in Handlers (#4680) Refactored all cBlockHandler and cItemHandler descendants to use Vector3. --- src/Blocks/BlockQuartz.h | 49 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) (limited to 'src/Blocks/BlockQuartz.h') diff --git a/src/Blocks/BlockQuartz.h b/src/Blocks/BlockQuartz.h index c87240cf1..27d6b9984 100644 --- a/src/Blocks/BlockQuartz.h +++ b/src/Blocks/BlockQuartz.h @@ -7,42 +7,57 @@ -class cBlockQuartzHandler : public cBlockHandler +class cBlockQuartzHandler: + public cBlockHandler { + using Super = cBlockHandler; + public: - cBlockQuartzHandler(BLOCKTYPE a_BlockType) - : cBlockHandler(a_BlockType) + + cBlockQuartzHandler(BLOCKTYPE a_BlockType): + Super(a_BlockType) { } + + + + virtual bool GetPlacementBlockTypeMeta( - cChunkInterface & a_ChunkInterface, cPlayer & a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, - int a_CursorX, int a_CursorY, int a_CursorZ, + cChunkInterface & a_ChunkInterface, + cPlayer & a_Player, + const Vector3i a_PlacedBlockPos, + eBlockFace a_ClickedBlockFace, + const Vector3i a_CursorPos, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override { a_BlockType = m_BlockType; - NIBBLETYPE Meta = static_cast(a_Player.GetEquippedItem().m_ItemDamage); + auto Meta = static_cast(a_Player.GetEquippedItem().m_ItemDamage); - if (Meta != E_META_QUARTZ_PILLAR) // Check if the block is a pillar block. + // Pillar block needs additional direction in the metadata: + if (Meta != E_META_QUARTZ_PILLAR) { a_BlockMeta = Meta; return true; } - - a_BlockMeta = BlockFaceToMetaData(a_BlockFace, Meta); + a_BlockMeta = BlockFaceToMetaData(a_ClickedBlockFace); return true; } - inline static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_BlockFace, NIBBLETYPE a_QuartzMeta) + + + + + /** Converts the block face of the pillar block's "base" to the block's metadata. */ + inline static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_BlockFace) { switch (a_BlockFace) { case BLOCK_FACE_YM: case BLOCK_FACE_YP: { - return a_QuartzMeta; // Top or bottom, just return original + return E_META_QUARTZ_PILLAR; // Top or bottom } case BLOCK_FACE_ZP: @@ -57,15 +72,17 @@ public: return 0x3; // East or west } - case BLOCK_FACE_NONE: + default: { - ASSERT(!"Unhandled block face!"); - return a_QuartzMeta; // No idea, give a special meta (all sides the same) + return E_META_QUARTZ_PILLAR; } } - UNREACHABLE("Unsupported block face"); } + + + + virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override { UNUSED(a_Meta); -- cgit v1.2.3