1
0
Fork 0

Fixing grass not generating below trees (#5199)

* moves the y-Position below the tree on grass generation
This commit is contained in:
12xx12 2021-04-23 21:00:02 +02:00 committed by GitHub
parent d117a6c5db
commit 4a2d0ce9d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 0 deletions

View File

@ -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) ||