diff options
author | Mattes D <github@xoft.cz> | 2019-10-16 10:06:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-16 10:06:34 +0200 |
commit | 221cc4ec5cb6301743e947eaabed3fecedba796f (patch) | |
tree | 4e44c8bb7523e5d1d04468fc906ae24674c10abc /src/Blocks/BlockDropSpenser.h | |
parent | Fixed crash in hopper while pulling items from blockentity above itself (#4412) (diff) | |
download | cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar.gz cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar.bz2 cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar.lz cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar.xz cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar.zst cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Blocks/BlockDropSpenser.h | 42 |
1 files changed, 33 insertions, 9 deletions
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<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04> { + using super = cMetaRotator<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>; + public: - cBlockDropSpenserHandler(BLOCKTYPE a_BlockType) : - cMetaRotator<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>(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<cDropSpenserEntity *>(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); |