summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorworktycho <work.tycho@gmail.com>2015-06-22 20:53:13 +0200
committerworktycho <work.tycho@gmail.com>2015-06-22 20:53:13 +0200
commit532c80b6dbe5b73e475ad802e35762e70086443c (patch)
treeca4ab1f53d9db787f40c01264d8f0f1ddc49cd49
parentMerge pull request #2274 from cuberite/ItemsRemovalFix (diff)
parentRebased version of Code (diff)
downloadcuberite-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
-rw-r--r--src/BlockInfo.cpp2
-rw-r--r--src/Blocks/BlockBed.h5
-rw-r--r--src/Blocks/BlockDirt.h35
-rw-r--r--src/Blocks/BlockFluid.h6
-rw-r--r--src/Blocks/BlockHandler.cpp9
-rw-r--r--src/Blocks/BlockHandler.h3
-rw-r--r--src/Blocks/BlockSlab.h6
-rw-r--r--src/Blocks/BlockStairs.h6
-rw-r--r--tests/LoadablePieces/Stubs.cpp9
9 files changed, 17 insertions, 64 deletions
diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp
index 04d214b01..44b1772e2 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 = 1;
+ a_Info[E_BLOCK_FARMLAND ].m_SpreadLightFalloff = 15;
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;
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
diff --git a/tests/LoadablePieces/Stubs.cpp b/tests/LoadablePieces/Stubs.cpp
index b1f61212b..0a8f2cb63 100644
--- a/tests/LoadablePieces/Stubs.cpp
+++ b/tests/LoadablePieces/Stubs.cpp
@@ -193,15 +193,6 @@ bool cBlockHandler::CanBeAt(cChunkInterface & a_ChunkInterface, int a_BlockX, in
-bool cBlockHandler::CanDirtGrowGrass(NIBBLETYPE a_Meta)
-{
- return true;
-}
-
-
-
-
-
bool cBlockHandler::IsUseable()
{
return false;