summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockPlant.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Blocks/BlockPlant.h')
-rw-r--r--src/Blocks/BlockPlant.h66
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
+ }
+ }
};