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/BlockDropSpenser.h | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) (limited to 'src/Blocks/BlockDropSpenser.h') diff --git a/src/Blocks/BlockDropSpenser.h b/src/Blocks/BlockDropSpenser.h index 2700b416c..ce98940d2 100644 --- a/src/Blocks/BlockDropSpenser.h +++ b/src/Blocks/BlockDropSpenser.h @@ -6,7 +6,8 @@ #pragma once #include "../Blocks/BlockPiston.h" -#include "MetaRotator.h" +#include "../BlockEntities/DropSpenserEntity.h" +#include "Mixins.h" @@ -15,12 +16,19 @@ class cBlockDropSpenserHandler : public cMetaRotator { + using super = cMetaRotator; + public: - cBlockDropSpenserHandler(BLOCKTYPE a_BlockType) : - cMetaRotator(a_BlockType) + + cBlockDropSpenserHandler(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, @@ -35,18 +43,30 @@ public: return true; } - /** Called when the drop / dispenser is convert into pickup, ignore meta data */ - 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 { - UNUSED(a_BlockMeta); - a_Pickups.push_back(cItem(m_BlockType, 1)); + cItems res(cItem(m_BlockType, 1)); + if (a_BlockEntity != nullptr) + { + auto be = static_cast(a_BlockEntity); + res.AddItemGrid(be->GetContents()); + } + return res; } + + + + virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) override { - // Bit 0x08 is a flag. Lowest three bits are position. 0x08 == 1000 + // Bit 0x08 is a flag. Lowest three bits are position. NIBBLETYPE OtherMeta = a_Meta & 0x08; - // Mirrors defined by by a table. (Source, mincraft.gamepedia.com) 0x07 == 0111 + // Mirrors defined by a table. (Source, minecraft.gamepedia.com) switch (a_Meta & 0x07) { case 0x00: return 0x01 + OtherMeta; // Down -> Up @@ -56,6 +76,10 @@ public: return a_Meta; } + + + + virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override { UNUSED(a_Meta); -- cgit v1.2.3