summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockVine.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2020-04-17 11:36:37 +0200
committerGitHub <noreply@github.com>2020-04-17 11:36:37 +0200
commit26ac146f41091dc070d8075f5fc9de25b5a22578 (patch)
tree5be089162a23ad2f2822be7b5d5d7cebbb958406 /src/Blocks/BlockVine.h
parentImplement glowing redstone ore (diff)
downloadcuberite-26ac146f41091dc070d8075f5fc9de25b5a22578.tar
cuberite-26ac146f41091dc070d8075f5fc9de25b5a22578.tar.gz
cuberite-26ac146f41091dc070d8075f5fc9de25b5a22578.tar.bz2
cuberite-26ac146f41091dc070d8075f5fc9de25b5a22578.tar.lz
cuberite-26ac146f41091dc070d8075f5fc9de25b5a22578.tar.xz
cuberite-26ac146f41091dc070d8075f5fc9de25b5a22578.tar.zst
cuberite-26ac146f41091dc070d8075f5fc9de25b5a22578.zip
Diffstat (limited to '')
-rw-r--r--src/Blocks/BlockVine.h18
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));
}
}
}