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/BlockChest.h | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) (limited to 'src/Blocks/BlockChest.h') diff --git a/src/Blocks/BlockChest.h b/src/Blocks/BlockChest.h index 804c3d34a..0e277532e 100644 --- a/src/Blocks/BlockChest.h +++ b/src/Blocks/BlockChest.h @@ -1,24 +1,31 @@ #pragma once -#include "BlockEntity.h" +#include "../BlockEntities/ChestEntity.h" #include "../BlockArea.h" #include "../Entities/Player.h" -#include "MetaRotator.h" +#include "Mixins.h" class cBlockChestHandler : - public cMetaRotator + public cMetaRotator, 0x07, 0x02, 0x05, 0x03, 0x04> { + using super = cMetaRotator, 0x07, 0x02, 0x05, 0x03, 0x04>; + public: - cBlockChestHandler(BLOCKTYPE a_BlockType) - : cMetaRotator(a_BlockType) + + cBlockChestHandler(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, @@ -65,6 +72,10 @@ public: return true; } + + + + virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width; @@ -72,6 +83,10 @@ public: return CanBeAt(a_ChunkInterface, BlockX, a_RelY, BlockZ); } + + + + virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { cBlockArea Area; @@ -137,6 +152,10 @@ public: return (NumChestNeighbors < 2); } + + + + /** Translates player yaw when placing a chest into the chest block metadata. Valid for single chests only */ static NIBBLETYPE PlayerYawToMetaData(double a_Yaw) { @@ -164,6 +183,10 @@ public: } } + + + + /** If there's a chest in the a_Area in the specified coords, modifies its meta to a_NewMeta and returns true. */ bool CheckAndAdjustNeighbor(cChunkInterface & a_ChunkInterface, const cBlockArea & a_Area, int a_RelX, int a_RelZ, NIBBLETYPE a_NewMeta) { @@ -175,10 +198,9 @@ public: return true; } - virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override - { - a_Pickups.push_back(cItem(m_BlockType, 1, 0)); - } + + + virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override { -- cgit v1.2.3