summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockPlant.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-09-20 15:50:52 +0200
committerGitHub <noreply@github.com>2020-09-20 15:50:52 +0200
commit68cced73afe546328cf94ed07c57deee47bfadec (patch)
tree88be88e3fd4a208b9849e526f1877caa44058ab5 /src/Blocks/BlockPlant.h
parentAdded armor and shulker box cleaning (#4875) (diff)
downloadcuberite-68cced73afe546328cf94ed07c57deee47bfadec.tar
cuberite-68cced73afe546328cf94ed07c57deee47bfadec.tar.gz
cuberite-68cced73afe546328cf94ed07c57deee47bfadec.tar.bz2
cuberite-68cced73afe546328cf94ed07c57deee47bfadec.tar.lz
cuberite-68cced73afe546328cf94ed07c57deee47bfadec.tar.xz
cuberite-68cced73afe546328cf94ed07c57deee47bfadec.tar.zst
cuberite-68cced73afe546328cf94ed07c57deee47bfadec.zip
Diffstat (limited to 'src/Blocks/BlockPlant.h')
-rw-r--r--src/Blocks/BlockPlant.h22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/Blocks/BlockPlant.h b/src/Blocks/BlockPlant.h
index a0d6ffe52..e99a0b130 100644
--- a/src/Blocks/BlockPlant.h
+++ b/src/Blocks/BlockPlant.h
@@ -14,17 +14,11 @@ class cBlockPlant:
{
using Super = cBlockHandler;
-
public:
- cBlockPlant(BLOCKTYPE a_BlockType):
- Super(a_BlockType)
- {
- }
-
-
-
+ using Super::Super;
+private:
virtual void OnUpdate(
cChunkInterface & a_ChunkInterface,
@@ -32,7 +26,7 @@ public:
cBlockPluginInterface & a_PluginInterface,
cChunk & a_Chunk,
const Vector3i a_RelPos
- ) override
+ ) const override
{
auto Action = CanGrow(a_Chunk, a_RelPos);
switch (Action)
@@ -74,7 +68,7 @@ protected:
If the plant requires light to grow and there is enough light, it returns paGrowth.
If the plant requires light to grow and there isn't enough light, it returns paStay.
If the plant requires light to grow and there is too little light, it returns paDeath. */
- PlantAction HasEnoughLight(cChunk & a_Chunk, Vector3i a_RelPos)
+ static PlantAction HasEnoughLight(cChunk & a_Chunk, Vector3i a_RelPos)
{
// If the plant requires light to grow, check to see if there is enough light
// Otherwise, return true
@@ -117,7 +111,7 @@ protected:
paDeath is returned when there isn't enough light for the plant to survive.
Plants that don't require light will never have a paDeath returned
*/
- virtual PlantAction CanGrow(cChunk & a_Chunk, Vector3i a_RelPos)
+ virtual PlantAction CanGrow(cChunk & a_Chunk, Vector3i a_RelPos) const
{
// Plant can grow if it has the required amount of light, and it passes a random chance based on surrounding blocks
auto action = HasEnoughLight(a_Chunk, a_RelPos);
@@ -134,7 +128,7 @@ protected:
/** Generates an int value between 4 and 25 based on surrounding blocks that affect how quickly the plant grows.
The higher the value, the less likely the plant is to grow */
- virtual int GetGrowthChance(cChunk & a_Chunk, Vector3i a_RelPos)
+ virtual int GetGrowthChance(cChunk & a_Chunk, Vector3i a_RelPos) const
{
float Chance = 1.0f;
a_RelPos.y -= 1;
@@ -149,10 +143,8 @@ protected:
// If the chunk we are trying to get the block information from is loaded
if (a_Chunk.UnboundedRelGetBlock(a_RelPos + Vector3i(x, 0, z), Block, Meta))
{
- cBlockHandler * Handler = BlockHandler(Block);
-
// If the block affects growth, add to the adjustment
- if (Handler->CanSustainPlant(m_BlockType))
+ if (cBlockHandler::For(Block).CanSustainPlant(m_BlockType))
{
Adjustment = 1.0f;