summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockStems.h
diff options
context:
space:
mode:
authorSamuel Barney <samjbarney@gmail.com>2015-08-19 18:45:53 +0200
committerSamuel Barney <samjbarney@gmail.com>2015-08-19 18:48:21 +0200
commitcc83c4641d50818bf4fd830653438515ed5264d3 (patch)
treed4c4ebe5a88eaeba8ce9d53122c9eb92e297870c /src/Blocks/BlockStems.h
parentMerge pull request #2439 from cuberite/AppveyorYml (diff)
downloadcuberite-cc83c4641d50818bf4fd830653438515ed5264d3.tar
cuberite-cc83c4641d50818bf4fd830653438515ed5264d3.tar.gz
cuberite-cc83c4641d50818bf4fd830653438515ed5264d3.tar.bz2
cuberite-cc83c4641d50818bf4fd830653438515ed5264d3.tar.lz
cuberite-cc83c4641d50818bf4fd830653438515ed5264d3.tar.xz
cuberite-cc83c4641d50818bf4fd830653438515ed5264d3.tar.zst
cuberite-cc83c4641d50818bf4fd830653438515ed5264d3.zip
Diffstat (limited to 'src/Blocks/BlockStems.h')
-rw-r--r--src/Blocks/BlockStems.h33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/Blocks/BlockStems.h b/src/Blocks/BlockStems.h
index 13b7a599f..df832c55a 100644
--- a/src/Blocks/BlockStems.h
+++ b/src/Blocks/BlockStems.h
@@ -1,7 +1,7 @@
#pragma once
-#include "BlockHandler.h"
+#include "BlockPlant.h"
#include "../World.h"
@@ -9,11 +9,12 @@
class cBlockStemsHandler :
- public cBlockHandler
+ public cBlockPlant
{
+ typedef cBlockPlant Super;
public:
cBlockStemsHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
+ : Super(a_BlockType, true)
{
}
@@ -25,18 +26,26 @@ public:
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
{
- NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
- if (Meta >= 7)
+ auto Action = CanGrow(a_Chunk, a_RelX, a_RelY, a_RelZ);
+ if (Action == paGrowth)
{
- // Grow the produce:
- int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
- int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
- a_Chunk.GetWorld()->GrowMelonPumpkin(BlockX, a_RelY, BlockZ, m_BlockType);
+ NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
+ if (Meta >= 7)
+ {
+ // Grow the produce:
+ int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
+ int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
+ a_Chunk.GetWorld()->GrowMelonPumpkin(BlockX, a_RelY, BlockZ, m_BlockType);
+ }
+ else
+ {
+ // Grow the stem:
+ a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, m_BlockType, Meta + 1);
+ }
}
- else
+ else if (Action == paDeath)
{
- // Grow the stem:
- a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, m_BlockType, Meta + 1);
+ a_Chunk.GetWorld()->DigBlock(a_RelX + a_Chunk.GetPosX() * cChunkDef::Width, a_RelY, a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width);
}
}