From 4a2d0ce9d32eac0df2acb116e6242490b2adf868 Mon Sep 17 00:00:00 2001 From: 12xx12 <44411062+12xx12@users.noreply.github.com> Date: Fri, 23 Apr 2021 21:00:02 +0200 Subject: Fixing grass not generating below trees (#5199) * moves the y-Position below the tree on grass generation --- src/Generating/FinishGen.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/Generating') diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index e9bf69f55..ef4af91c5 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -542,6 +542,32 @@ void cFinishGenTallGrass::GenFinish(cChunkDesc & a_ChunkDesc) continue; } + // Walk below trees: + auto BlockBelow = a_ChunkDesc.GetBlockType(x, y - 1, z); + bool failed = false; // marker if the search for a valid position was successful + + while ( + (BlockBelow == E_BLOCK_LEAVES) || + (BlockBelow == E_BLOCK_NEW_LEAVES) || + (BlockBelow == E_BLOCK_LOG) || + (BlockBelow == E_BLOCK_NEW_LOG) || + (BlockBelow == E_BLOCK_AIR) + ) + { + y--; + if (!cChunkDef::IsValidHeight(y - 1)) + { + failed = true; + break; + } + BlockBelow = a_ChunkDesc.GetBlockType(x, y - 1, z); + } + + if (failed) + { + continue; + } + // Check if long grass can be placed: if ( (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) || -- cgit v1.2.3