From ba664340f3d170eac703c15a6f2c672c906ec939 Mon Sep 17 00:00:00 2001 From: Lukas Pioch Date: Sun, 29 Sep 2019 09:54:09 +0200 Subject: Cactus can now grow and will be dropped if there is no place to grow. --- src/Chunk.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 9b9c881b7..a4a315bc0 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -1145,7 +1145,7 @@ int cChunk::GrowCactus(int a_RelX, int a_RelY, int a_RelZ, int a_NumBlocks) for (auto & Coord : Coords) { if ( - UnboundedRelGetBlockType(a_RelX + Coord.x, Top + 1, a_RelZ + Coord.z, BlockType) && + UnboundedRelGetBlockType(a_RelX + Coord.x, Top + i, a_RelZ + Coord.z, BlockType) && ( cBlockInfo::IsSolid(BlockType) || (BlockType == E_BLOCK_LAVA) || @@ -1153,12 +1153,25 @@ int cChunk::GrowCactus(int a_RelX, int a_RelY, int a_RelZ, int a_NumBlocks) ) ) { + // Remove the cactus + GetWorld()->DigBlock(a_RelX + GetPosX() * cChunkDef::Width, Top + i, a_RelZ + GetPosZ() * cChunkDef::Width); + + // Drop the cactus on the other side of the blocking block + cBlockHandler * Handler = BlockHandler(E_BLOCK_CACTUS); + cChunkInterface ChunkInterface(GetWorld()->GetChunkMap()); + cBlockInServerPluginInterface PluginInterface(*GetWorld()); + Handler->DropBlock( + ChunkInterface, + *GetWorld(), + PluginInterface, + nullptr, + a_RelX + GetPosX() * cChunkDef::Width - Coord.x, + Top + i, + a_RelZ + GetPosZ() * cChunkDef::Width - Coord.z + ); return false; } } // for i - Coords[] - { - GetWorld()->DigBlock(a_RelX + GetPosX() * cChunkDef::Width, Top + i, a_RelZ + GetPosZ() * cChunkDef::Width); - } } else { -- cgit v1.2.3