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/BlockLever.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 'src/Blocks/BlockLever.h')
-rw-r--r-- | src/Blocks/BlockLever.h | 55 |
1 files changed, 50 insertions, 5 deletions
diff --git a/src/Blocks/BlockLever.h b/src/Blocks/BlockLever.h index 6cb80222e..e4b181a24 100644 --- a/src/Blocks/BlockLever.h +++ b/src/Blocks/BlockLever.h @@ -2,21 +2,26 @@ #include "BlockHandler.h" #include "../Chunk.h" -#include "MetaRotator.h" +#include "Mixins.h" #include "BlockSlab.h" class cBlockLeverHandler : public cMetaRotator<cBlockHandler, 0x07, 0x04, 0x01, 0x03, 0x02, false> { - typedef cMetaRotator<cBlockHandler, 0x07, 0x04, 0x01, 0x03, 0x02, false> super; + using super = cMetaRotator<cBlockHandler, 0x07, 0x04, 0x01, 0x03, 0x02, false>; public: + cBlockLeverHandler(BLOCKTYPE a_BlockType) : super(a_BlockType) { } + + + + virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override { Vector3i Coords(a_BlockX, a_BlockY, a_BlockZ); @@ -29,17 +34,29 @@ public: return true; } - 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 { - // Reset meta to 0 - a_Pickups.push_back(cItem(E_BLOCK_LEVER, 1, 0)); + // Reset meta to zero: + return cItem(E_BLOCK_LEVER, 1, 0); } + + + + virtual bool IsUseable(void) override { return true; } + + + + virtual bool GetPlacementBlockTypeMeta( cChunkInterface & a_ChunkInterface, cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, @@ -52,6 +69,10 @@ public: return true; } + + + + inline static NIBBLETYPE LeverDirectionToMetaData(eBlockFace a_Dir) { // Determine lever direction: @@ -68,6 +89,10 @@ public: UNREACHABLE("Unsupported block face"); } + + + + inline static eBlockFace BlockMetaDataToBlockFace(NIBBLETYPE a_Meta) { switch (a_Meta & 0x7) @@ -88,6 +113,10 @@ public: } } + + + + virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ); @@ -121,6 +150,10 @@ public: return false; } + + + + virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override { switch (a_Meta) @@ -135,6 +168,10 @@ public: } } + + + + virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override { switch (a_Meta) @@ -149,12 +186,20 @@ public: } } + + + + virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override { UNUSED(a_Meta); return 0; } + + + + /** Extracts the ON bit from metadata and returns if true if it is set */ static bool IsLeverOn(NIBBLETYPE a_BlockMeta) { |