diff options
Diffstat (limited to 'src/Blocks/BlockDirt.h')
-rw-r--r-- | src/Blocks/BlockDirt.h | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/src/Blocks/BlockDirt.h b/src/Blocks/BlockDirt.h index 32512a2ef..3d671d218 100644 --- a/src/Blocks/BlockDirt.h +++ b/src/Blocks/BlockDirt.h @@ -3,6 +3,7 @@ #include "BlockHandler.h" #include "../FastRandom.h" +#include "../BlockInfo.h" #include "Root.h" #include "Bindings/PluginManager.h" @@ -39,19 +40,6 @@ public: { return; } - - // Grass becomes dirt if there is something on top of it: - if (a_RelY < cChunkDef::Height - 1) - { - BLOCKTYPE Above; - NIBBLETYPE AboveMeta; - a_Chunk.GetBlockTypeMeta(a_RelX, a_RelY + 1, a_RelZ, Above, AboveMeta); - if (!cBlockInfo::GetHandler(Above)->CanDirtGrowGrass(AboveMeta)) - { - a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_DIRT, E_META_DIRT_NORMAL); - return; - } - } // Make sure that there is enough light at the source block to spread if (!a_Chunk.GetWorld()->IsChunkLighted(a_Chunk.GetPosX(), a_Chunk.GetPosZ())) @@ -59,10 +47,24 @@ public: a_Chunk.GetWorld()->QueueLightChunk(a_Chunk.GetPosX(), a_Chunk.GetPosZ()); return; } - else if ((a_RelY < cChunkDef::Height - 1) && std::max(a_Chunk.GetBlockLight(a_RelX, a_RelY + 1, a_RelZ), a_Chunk.GetTimeAlteredLight(a_Chunk.GetSkyLight(a_RelX, a_RelY + 1, a_RelZ))) < 9) + else if ((a_RelY < cChunkDef::Height - 1)) { + BLOCKTYPE above = a_Chunk.GetBlock(a_RelX, a_RelY + 1, a_RelZ); + + // Grass turns back to dirt when the block above is not transparent + if (!cBlockInfo::IsTransparent(above)) + { + a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_DIRT, E_META_DIRT_NORMAL); + return; + } + + NIBBLETYPE light = std::max(a_Chunk.GetBlockLight(a_RelX, a_RelY + 1, a_RelZ), a_Chunk.GetTimeAlteredLight(a_Chunk.GetSkyLight(a_RelX, a_RelY + 1, a_RelZ))); // Source block is not bright enough to spread - return; + if (light < 9) + { + return; + } + } // Grass spreads to adjacent dirt blocks: @@ -95,11 +97,10 @@ public: // Not a regular dirt block continue; } - - BLOCKTYPE AboveDest; - NIBBLETYPE AboveMeta; - Chunk->GetBlockTypeMeta(BlockX, BlockY + 1, BlockZ, AboveDest, AboveMeta); - if (cBlockInfo::GetHandler(AboveDest)->CanDirtGrowGrass(AboveMeta)) + BLOCKTYPE above = a_Chunk.GetBlock(BlockX, BlockY + 1, BlockZ); + NIBBLETYPE light = std::max(a_Chunk.GetBlockLight(BlockX, BlockY + 1, BlockZ), a_Chunk.GetTimeAlteredLight(a_Chunk.GetSkyLight(BlockX, BlockY + 1, BlockZ))); + // Grass does not spread to blocks with a light level less than 5 + if ((light > 4) && cBlockInfo::IsTransparent(above)) { if (!cRoot::Get()->GetPluginManager()->CallHookBlockSpread(*Chunk->GetWorld(), Chunk->GetPosX() * cChunkDef::Width + BlockX, BlockY, Chunk->GetPosZ() * cChunkDef::Width + BlockZ, ssGrassSpread)) { |