summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockNetherWart.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2019-10-11 11:02:53 +0200
committerMattes D <github@xoft.cz>2019-10-28 10:45:43 +0100
commit61904af626b036b6e4e045ca219b2a361aa45a6e (patch)
tree60b99ab37c9ec87ca96d403b3254a4da023cf6ac /src/Blocks/BlockNetherWart.h
parentUpdate README.md (#4423) (diff)
downloadcuberite-61904af626b036b6e4e045ca219b2a361aa45a6e.tar
cuberite-61904af626b036b6e4e045ca219b2a361aa45a6e.tar.gz
cuberite-61904af626b036b6e4e045ca219b2a361aa45a6e.tar.bz2
cuberite-61904af626b036b6e4e045ca219b2a361aa45a6e.tar.lz
cuberite-61904af626b036b6e4e045ca219b2a361aa45a6e.tar.xz
cuberite-61904af626b036b6e4e045ca219b2a361aa45a6e.tar.zst
cuberite-61904af626b036b6e4e045ca219b2a361aa45a6e.zip
Diffstat (limited to '')
-rw-r--r--src/Blocks/BlockNetherWart.h17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/Blocks/BlockNetherWart.h b/src/Blocks/BlockNetherWart.h
index 6b0b394b5..5664093e9 100644
--- a/src/Blocks/BlockNetherWart.h
+++ b/src/Blocks/BlockNetherWart.h
@@ -42,17 +42,22 @@ 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
+ virtual int Grow(cChunk & a_Chunk, Vector3i a_RelPos, int a_NumStages = 1) override
{
- NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
- if ((Meta < 3) && (CanGrow(a_Chunk, a_RelX, a_RelY, a_RelZ) == paGrowth))
+ auto oldMeta = a_Chunk.GetMeta(a_RelPos);
+ auto meta = std::min(oldMeta + a_NumStages, 3);
+ if ((oldMeta < 3) && (CanGrow(a_Chunk, a_RelPos) == paGrowth))
{
- a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_NETHER_WART, ++Meta);
+ a_Chunk.SetBlock(a_RelPos, m_BlockType, static_cast<NIBBLETYPE>(meta));
+ return meta - oldMeta;
}
- else if (Meta > 3) // In older versions of cuberite, there was a bug which made wart grow too much. This check fixes previously saved buggy warts.
+
+ // In older versions of cuberite, there was a bug which made wart grow too much. This check fixes previously saved buggy warts.
+ if (oldMeta > 3)
{
- a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_NETHER_WART, 3);
+ a_Chunk.FastSetBlock(a_RelPos, m_BlockType, 3);
}
+ return 0;
}