diff options
author | worktycho <work.tycho@gmail.com> | 2015-06-22 20:53:13 +0200 |
---|---|---|
committer | worktycho <work.tycho@gmail.com> | 2015-06-22 20:53:13 +0200 |
commit | 532c80b6dbe5b73e475ad802e35762e70086443c (patch) | |
tree | ca4ab1f53d9db787f40c01264d8f0f1ddc49cd49 /src/Blocks | |
parent | Merge pull request #2274 from cuberite/ItemsRemovalFix (diff) | |
parent | Rebased version of Code (diff) | |
download | cuberite-532c80b6dbe5b73e475ad802e35762e70086443c.tar cuberite-532c80b6dbe5b73e475ad802e35762e70086443c.tar.gz cuberite-532c80b6dbe5b73e475ad802e35762e70086443c.tar.bz2 cuberite-532c80b6dbe5b73e475ad802e35762e70086443c.tar.lz cuberite-532c80b6dbe5b73e475ad802e35762e70086443c.tar.xz cuberite-532c80b6dbe5b73e475ad802e35762e70086443c.tar.zst cuberite-532c80b6dbe5b73e475ad802e35762e70086443c.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Blocks/BlockBed.h | 5 | ||||
-rw-r--r-- | src/Blocks/BlockDirt.h | 35 | ||||
-rw-r--r-- | src/Blocks/BlockFluid.h | 6 | ||||
-rw-r--r-- | src/Blocks/BlockHandler.cpp | 9 | ||||
-rw-r--r-- | src/Blocks/BlockHandler.h | 3 | ||||
-rw-r--r-- | src/Blocks/BlockSlab.h | 6 | ||||
-rw-r--r-- | src/Blocks/BlockStairs.h | 6 |
7 files changed, 16 insertions, 54 deletions
diff --git a/src/Blocks/BlockBed.h b/src/Blocks/BlockBed.h index 57ffebfca..905c0ea76 100644 --- a/src/Blocks/BlockBed.h +++ b/src/Blocks/BlockBed.h @@ -36,11 +36,6 @@ public: a_Pickups.push_back(cItem(E_ITEM_BED, 1, 0)); } - virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta) override - { - return true; - } - // Bed specific helper functions static NIBBLETYPE RotationToMetaData(double a_Rotation) diff --git a/src/Blocks/BlockDirt.h b/src/Blocks/BlockDirt.h index 32512a2ef..ce1b1d5bb 100644 --- a/src/Blocks/BlockDirt.h +++ b/src/Blocks/BlockDirt.h @@ -39,19 +39,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 +46,21 @@ 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)) { + 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) + { + 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 - return; + if (light < 9) + { + return; + } + } // Grass spreads to adjacent dirt blocks: @@ -96,10 +94,9 @@ public: continue; } - BLOCKTYPE AboveDest; - NIBBLETYPE AboveMeta; - Chunk->GetBlockTypeMeta(BlockX, BlockY + 1, BlockZ, AboveDest, AboveMeta); - if (cBlockInfo::GetHandler(AboveDest)->CanDirtGrowGrass(AboveMeta)) + 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 (!cRoot::Get()->GetPluginManager()->CallHookBlockSpread(*Chunk->GetWorld(), Chunk->GetPosX() * cChunkDef::Width + BlockX, BlockY, Chunk->GetPosZ() * cChunkDef::Width + BlockZ, ssGrassSpread)) { diff --git a/src/Blocks/BlockFluid.h b/src/Blocks/BlockFluid.h index 2823baedc..58b3ce042 100644 --- a/src/Blocks/BlockFluid.h +++ b/src/Blocks/BlockFluid.h @@ -49,12 +49,6 @@ public: } super::Check(a_ChunkInterface, a_PluginInterface, a_RelX, a_RelY, a_RelZ, a_Chunk); } - - - virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta) override - { - return false; - } } ; diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 105765b5f..520d0d328 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -513,15 +513,6 @@ bool cBlockHandler::CanBeAt(cChunkInterface & a_ChunkInterface, int a_BlockX, in -bool cBlockHandler::CanDirtGrowGrass(NIBBLETYPE a_Meta) -{ - return ((cBlockInfo::IsTransparent(m_BlockType)) || (cBlockInfo::IsOneHitDig(m_BlockType))); -} - - - - - bool cBlockHandler::IsUseable() { return false; diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index 4dec0dc95..a71c70e8b 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -83,9 +83,6 @@ public: /// Checks if the block can stay at the specified relative coords in the chunk virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk); - - /** Can the dirt under this block grow to grass? */ - virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta); /** Checks if the block can be placed at this point. Default: CanBeAt(...) diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h index 9b3fad72e..58e85013e 100644 --- a/src/Blocks/BlockSlab.h +++ b/src/Blocks/BlockSlab.h @@ -88,12 +88,6 @@ public: return true; } - - virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta) override - { - return ((a_Meta & 0x8) != 0); - } - /// Returns true if the specified blocktype is one of the slabs handled by this handler static bool IsAnySlabType(BLOCKTYPE a_BlockType) diff --git a/src/Blocks/BlockStairs.h b/src/Blocks/BlockStairs.h index d396204e0..7ef69d2ec 100644 --- a/src/Blocks/BlockStairs.h +++ b/src/Blocks/BlockStairs.h @@ -62,12 +62,6 @@ public: } - virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta) override - { - return true; - } - - static NIBBLETYPE RotationToMetaData(double a_Rotation) { a_Rotation += 90 + 45; // So its not aligned with axis |