diff options
author | Samuel Barney <samjbarney@gmail.com> | 2015-08-19 19:05:30 +0200 |
---|---|---|
committer | Samuel Barney <samjbarney@gmail.com> | 2015-08-19 19:05:30 +0200 |
commit | b5ed23d2a6696586b70b11a1bed51f4565079e5d (patch) | |
tree | d4c4ebe5a88eaeba8ce9d53122c9eb92e297870c /src/Blocks/BlockCrops.h | |
parent | Merge pull request #2439 from cuberite/AppveyorYml (diff) | |
parent | * Logic for handling plant growth has been centralized into cBlockPlant, and all growable plants now inherit from it. (diff) | |
download | cuberite-b5ed23d2a6696586b70b11a1bed51f4565079e5d.tar cuberite-b5ed23d2a6696586b70b11a1bed51f4565079e5d.tar.gz cuberite-b5ed23d2a6696586b70b11a1bed51f4565079e5d.tar.bz2 cuberite-b5ed23d2a6696586b70b11a1bed51f4565079e5d.tar.lz cuberite-b5ed23d2a6696586b70b11a1bed51f4565079e5d.tar.xz cuberite-b5ed23d2a6696586b70b11a1bed51f4565079e5d.tar.zst cuberite-b5ed23d2a6696586b70b11a1bed51f4565079e5d.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Blocks/BlockCrops.h | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/Blocks/BlockCrops.h b/src/Blocks/BlockCrops.h index c54625561..9014f7046 100644 --- a/src/Blocks/BlockCrops.h +++ b/src/Blocks/BlockCrops.h @@ -1,7 +1,7 @@ #pragma once -#include "BlockHandler.h" +#include "BlockPlant.h" #include "../FastRandom.h" @@ -10,11 +10,12 @@ /** Common class that takes care of carrots, potatoes and wheat */ class cBlockCropsHandler : - public cBlockHandler + public cBlockPlant { + typedef cBlockPlant Super; public: cBlockCropsHandler(BLOCKTYPE a_BlockType) - : cBlockHandler(a_BlockType) + : Super(a_BlockType, true) { } @@ -82,12 +83,17 @@ public: { Light = SkyLight; } - - if ((Meta < 7) && (Light > 8)) + + // Check to see if the plant can grow + auto Action = CanGrow(a_Chunk, a_RelX, a_RelY, a_RelZ); + + // If there is still room to grow and the plant can grow, then grow. + // Otherwise if the plant needs to die, then dig it up + if ((Meta < 7) && (Action == paGrowth)) { a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, m_BlockType, ++Meta); } - else if (Light < 9) + else if (Action == paDeath) { a_Chunk.GetWorld()->DigBlock(a_RelX + a_Chunk.GetPosX() * cChunkDef::Width, a_RelY, a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width); } |