diff options
Diffstat (limited to 'src/Blocks/BlockVine.h')
-rw-r--r-- | src/Blocks/BlockVine.h | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/Blocks/BlockVine.h b/src/Blocks/BlockVine.h index 9c3c1c53e..f8328f046 100644 --- a/src/Blocks/BlockVine.h +++ b/src/Blocks/BlockVine.h @@ -221,25 +221,33 @@ public: - virtual void OnUpdate(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override + virtual void OnUpdate( + cChunkInterface & a_ChunkInterface, + cWorldInterface & a_WorldInterface, + cBlockPluginInterface & a_PluginInterface, + cChunk & a_Chunk, + const Vector3i a_RelPos + ) override { UNUSED(a_ChunkInterface); UNUSED(a_WorldInterface); // Vine cannot grow down if at the bottom: - if (a_RelY < 1) + auto GrowPos = a_RelPos.addedY(-1); + if (!cChunkDef::IsValidHeight(GrowPos.y)) { return; } // Grow one block down, if possible: BLOCKTYPE Block; - a_Chunk.UnboundedRelGetBlockType(a_RelX, a_RelY - 1, a_RelZ, Block); + a_Chunk.UnboundedRelGetBlockType(GrowPos, Block); if (Block == E_BLOCK_AIR) { - if (!a_BlockPluginInterface.CallHookBlockSpread(a_RelX + a_Chunk.GetPosX() * cChunkDef::Width, a_RelY - 1, a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width, ssVineSpread)) + auto WorldPos = a_Chunk.RelativeToAbsolute(GrowPos); + if (!a_PluginInterface.CallHookBlockSpread(WorldPos.x, WorldPos.y, WorldPos.z, ssVineSpread)) { - a_Chunk.UnboundedRelSetBlock(a_RelX, a_RelY - 1, a_RelZ, E_BLOCK_VINES, a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ)); + a_Chunk.UnboundedRelSetBlock(GrowPos, E_BLOCK_VINES, a_Chunk.GetMeta(a_RelPos)); } } } |