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/BlockTripwireHook.h | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'src/Blocks/BlockTripwireHook.h') diff --git a/src/Blocks/BlockTripwireHook.h b/src/Blocks/BlockTripwireHook.h index d544fff86..8537f99ce 100644 --- a/src/Blocks/BlockTripwireHook.h +++ b/src/Blocks/BlockTripwireHook.h @@ -1,21 +1,28 @@ #pragma once #include "BlockHandler.h" -#include "MetaRotator.h" +#include "Mixins.h" class cBlockTripwireHookHandler : - public cMetaRotator + public cMetaRotator, 0x03, 0x02, 0x03, 0x00, 0x01> { + using super = cMetaRotator, 0x03, 0x02, 0x03, 0x00, 0x01>; + public: - cBlockTripwireHookHandler(BLOCKTYPE a_BlockType) - : cMetaRotator(a_BlockType) + + cBlockTripwireHookHandler(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, @@ -29,6 +36,10 @@ public: return true; } + + + + inline static NIBBLETYPE DirectionToMetadata(eBlockFace a_Direction) { switch (a_Direction) @@ -48,6 +59,10 @@ public: UNREACHABLE("Unsupported block face"); } + + + + inline static eBlockFace MetadataToDirection(NIBBLETYPE a_Meta) { switch (a_Meta & 0x03) @@ -60,11 +75,9 @@ public: } } - virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override - { - // Reset meta to zero - a_Pickups.push_back(cItem(E_BLOCK_TRIPWIRE_HOOK, 1, 0)); - } + + + virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { @@ -78,6 +91,10 @@ public: return ((a_RelY > 0) && cBlockInfo::FullyOccupiesVoxel(BlockIsOn)); } + + + + virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override { UNUSED(a_Meta); -- cgit v1.2.3