diff options
author | peterbell10 <peterbell10@live.co.uk> | 2020-10-05 12:27:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-05 12:27:14 +0200 |
commit | a9031b6bae742b333b1b390192fa590f2ecb07ea (patch) | |
tree | b2802c81d24d339c201a0747d66ba44e9ea8b1b0 /src/Blocks/BlockPlant.h | |
parent | Fixed current end generator (#4968) (diff) | |
download | cuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.tar cuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.tar.gz cuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.tar.bz2 cuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.tar.lz cuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.tar.xz cuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.tar.zst cuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Blocks/BlockPlant.h | 66 |
1 files changed, 30 insertions, 36 deletions
diff --git a/src/Blocks/BlockPlant.h b/src/Blocks/BlockPlant.h index e99a0b130..71890b3cf 100644 --- a/src/Blocks/BlockPlant.h +++ b/src/Blocks/BlockPlant.h @@ -9,7 +9,7 @@ /** Base class for plants that use light values to decide whether to grow or not. On block update, the plant decides whether to grow, die or stay as-is, based on the CanGrow() overridable method result. */ template <bool NeedsLightToGrow> -class cBlockPlant: +class cBlockPlant : public cBlockHandler { using Super = cBlockHandler; @@ -18,39 +18,10 @@ public: using Super::Super; -private: - - virtual void OnUpdate( - cChunkInterface & a_ChunkInterface, - cWorldInterface & a_WorldInterface, - cBlockPluginInterface & a_PluginInterface, - cChunk & a_Chunk, - const Vector3i a_RelPos - ) const override - { - auto Action = CanGrow(a_Chunk, a_RelPos); - switch (Action) - { - case paGrowth: - { - Grow(a_Chunk, a_RelPos); - break; - } - case paDeath: - { - a_ChunkInterface.SetBlock(a_Chunk.RelativeToAbsolute(a_RelPos), E_BLOCK_AIR, 0); - break; - } - case paStay: break; // do nothing - } - } - - - - - protected: + ~cBlockPlant() = default; + /** The action the plant can take on an update. */ enum PlantAction { @@ -59,10 +30,6 @@ protected: paStay }; - - - - /** Checks whether there is enough light for the plant to grow. If the plant doesn't require light to grow, then it returns paGrowth. If the plant requires light to grow and there is enough light, it returns paGrowth. @@ -167,4 +134,31 @@ protected: } return FloorC(24.0f / Chance) + 1; } + +private: + + virtual void OnUpdate( + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface, + cBlockPluginInterface & a_PluginInterface, + cChunk & a_Chunk, + const Vector3i a_RelPos + ) const override + { + auto Action = CanGrow(a_Chunk, a_RelPos); + switch (Action) + { + case paGrowth: + { + Grow(a_Chunk, a_RelPos); + break; + } + case paDeath: + { + a_ChunkInterface.SetBlock(a_Chunk.RelativeToAbsolute(a_RelPos), E_BLOCK_AIR, 0); + break; + } + case paStay: break; // do nothing + } + } }; |