summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockDirt.h
diff options
context:
space:
mode:
authorworktycho <work.tycho@gmail.com>2015-07-03 21:44:03 +0200
committerworktycho <work.tycho@gmail.com>2015-07-03 21:44:03 +0200
commitfa100d9345290de1a564a363b569cca624e78535 (patch)
tree604fb911a62ba9fe62b1eeea95b9709ed5416ce5 /src/Blocks/BlockDirt.h
parentMerge pull request #2306 from cuberite/FixNeighborChangedLoop (diff)
parentMoved grabbing the light value to after the transparency check. (diff)
downloadcuberite-fa100d9345290de1a564a363b569cca624e78535.tar
cuberite-fa100d9345290de1a564a363b569cca624e78535.tar.gz
cuberite-fa100d9345290de1a564a363b569cca624e78535.tar.bz2
cuberite-fa100d9345290de1a564a363b569cca624e78535.tar.lz
cuberite-fa100d9345290de1a564a363b569cca624e78535.tar.xz
cuberite-fa100d9345290de1a564a363b569cca624e78535.tar.zst
cuberite-fa100d9345290de1a564a363b569cca624e78535.zip
Diffstat (limited to 'src/Blocks/BlockDirt.h')
-rw-r--r--src/Blocks/BlockDirt.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/Blocks/BlockDirt.h b/src/Blocks/BlockDirt.h
index ce1b1d5bb..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"
@@ -48,13 +49,16 @@ public:
}
else if ((a_RelY < cChunkDef::Height - 1))
{
- 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)));
- // Grass turns back to dirt when light levels are below 5
- if (light < 5)
+ 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
if (light < 9)
{
@@ -93,10 +97,10 @@ public:
// Not a regular dirt block
continue;
}
-
+ 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)
+ 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))
{