diff options
Diffstat (limited to 'src/Blocks/BlockTallGrass.h')
-rw-r--r-- | src/Blocks/BlockTallGrass.h | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/src/Blocks/BlockTallGrass.h b/src/Blocks/BlockTallGrass.h index ea638c878..47ad2f93d 100644 --- a/src/Blocks/BlockTallGrass.h +++ b/src/Blocks/BlockTallGrass.h @@ -2,6 +2,7 @@ #pragma once #include "BlockHandler.h" +#include "Mixins/DirtLikeUnderneath.h" #include "ChunkInterface.h" @@ -10,9 +11,9 @@ /** Handles the grass that is 1 block tall */ class cBlockTallGrassHandler final : - public cBlockHandler + public cDirtLikeUnderneath<cBlockHandler> { - using Super = cBlockHandler; + using Super = cDirtLikeUnderneath<cBlockHandler>; public: @@ -52,25 +53,11 @@ private: - virtual bool CanBeAt(const cChunk & a_Chunk, const Vector3i a_Position, const NIBBLETYPE a_Meta) const override - { - if (a_Position.y <= 0) - { - return false; - } - - BLOCKTYPE BelowBlock = a_Chunk.GetBlock(a_Position.addedY(-1)); - return IsBlockTypeOfDirt(BelowBlock); - } - - - - - /** Growing a tall grass produces a big flower (2-block high fern or double-tall grass). */ virtual int Grow(cChunk & a_Chunk, Vector3i a_RelPos, int a_NumStages = 1) const override { - if (a_RelPos.y > (cChunkDef::Height - 2)) + const auto TopPos = a_RelPos.addedY(1); + if (!cChunkDef::IsValidHeight(TopPos)) { return 0; } @@ -83,7 +70,7 @@ private: default: return 0; } a_Chunk.SetBlock(a_RelPos, E_BLOCK_BIG_FLOWER, largeFlowerMeta); - a_Chunk.SetBlock(a_RelPos.addedY(1), E_BLOCK_BIG_FLOWER, E_META_BIG_FLOWER_TOP); + a_Chunk.SetBlock(TopPos, E_BLOCK_BIG_FLOWER, E_META_BIG_FLOWER_TOP); return 1; } |