From 404cf5dcfdeeb1f5af129039d9eaaf134a4dd3e0 Mon Sep 17 00:00:00 2001 From: Samuel Barney Date: Thu, 2 Jul 2015 16:13:40 -0600 Subject: Farmland is now listed as an opaque block. Changed spread light falloff for farmland to what it was originally. --- src/BlockInfo.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index 44b1772e2..c0ae5e945 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -86,7 +86,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_ENDER_CHEST ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_END_PORTAL ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_END_PORTAL_FRAME ].m_SpreadLightFalloff = 1; - a_Info[E_BLOCK_FARMLAND ].m_SpreadLightFalloff = 15; + a_Info[E_BLOCK_FARMLAND ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_FENCE ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_FENCE_GATE ].m_SpreadLightFalloff = 1; a_Info[E_BLOCK_FIRE ].m_SpreadLightFalloff = 1; @@ -204,7 +204,6 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info) a_Info[E_BLOCK_ENDER_CHEST ].m_Transparent = true; a_Info[E_BLOCK_END_PORTAL ].m_Transparent = true; a_Info[E_BLOCK_END_PORTAL_FRAME ].m_Transparent = true; - a_Info[E_BLOCK_FARMLAND ].m_Transparent = true; a_Info[E_BLOCK_FENCE ].m_Transparent = true; a_Info[E_BLOCK_FENCE_GATE ].m_Transparent = true; a_Info[E_BLOCK_FIRE ].m_Transparent = true; -- cgit v1.2.3 From e248539d7450fd73e85d8a71a086fbac9fe1ee48 Mon Sep 17 00:00:00 2001 From: Samuel Barney Date: Thu, 2 Jul 2015 16:16:05 -0600 Subject: Grass now only dies if it has an opaque block above it. Grass only spreads to a dirt block if the light level is above 4 and the block above it is transparent. --- src/Blocks/BlockDirt.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Blocks/BlockDirt.h b/src/Blocks/BlockDirt.h index ce1b1d5bb..1411b51f2 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,15 @@ public: } else if ((a_RelY < cChunkDef::Height - 1)) { + BLOCKTYPE above = a_Chunk.GetBlock(a_RelX, a_RelY + 1, a_RelZ); 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) + // Grass turns back to dirt when light levels are below 5 and 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; } + // Source block is not bright enough to spread if (light < 9) { @@ -93,10 +96,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)) { -- cgit v1.2.3 From 0307b6aba07048ea5bde295aa734c0a5af126e1c Mon Sep 17 00:00:00 2001 From: Samuel Barney Date: Thu, 2 Jul 2015 16:19:23 -0600 Subject: Added missing parens --- src/Blocks/BlockDirt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Blocks/BlockDirt.h b/src/Blocks/BlockDirt.h index 1411b51f2..335aef08a 100644 --- a/src/Blocks/BlockDirt.h +++ b/src/Blocks/BlockDirt.h @@ -99,7 +99,7 @@ public: 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 ((light > 4) && cBlockInfo::IsTransparent(above)) { if (!cRoot::Get()->GetPluginManager()->CallHookBlockSpread(*Chunk->GetWorld(), Chunk->GetPosX() * cChunkDef::Width + BlockX, BlockY, Chunk->GetPosZ() * cChunkDef::Width + BlockZ, ssGrassSpread)) { -- cgit v1.2.3 From ba0577bbd0913c381124ab0695d767efa8d26ffa Mon Sep 17 00:00:00 2001 From: Samuel Barney Date: Fri, 3 Jul 2015 13:05:02 -0600 Subject: Moved grabbing the light value to after the transparency check. --- src/Blocks/BlockDirt.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Blocks/BlockDirt.h b/src/Blocks/BlockDirt.h index 335aef08a..3d671d218 100644 --- a/src/Blocks/BlockDirt.h +++ b/src/Blocks/BlockDirt.h @@ -50,14 +50,15 @@ public: else if ((a_RelY < cChunkDef::Height - 1)) { BLOCKTYPE above = a_Chunk.GetBlock(a_RelX, a_RelY + 1, a_RelZ); - 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 and the block above is not transparent + + // 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) { -- cgit v1.2.3