Merge pull request #2280 from SamJBarney/master
Rebased version of Code for Grass Growth Fix
This commit is contained in:
commit
532c80b6db
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -40,29 +40,27 @@ 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()))
|
||||
{
|
||||
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))
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -84,9 +84,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(...)
|
||||
NOTE: This call doesn't actually place the block
|
||||
|
@ -89,12 +89,6 @@ public:
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user