From a9031b6bae742b333b1b390192fa590f2ecb07ea Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Mon, 5 Oct 2020 11:27:14 +0100 Subject: Fix cmake not adding Werror on clang, and _lots_ of warnings (#4963) * Fix cmake not adding Werror on clang, and _lots_ of warnings * WIP: Build fixes * Cannot make intermediate blockhandler instance * Tiger's changes * Fix BitIndex check * Handle invalid NextState values in cMultiVersionProtocol Co-authored-by: Tiger Wang --- src/Blocks/BlockPlant.h | 66 ++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 36 deletions(-) (limited to 'src/Blocks/BlockPlant.h') 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 -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 + } + } }; -- cgit v1.2.3