Rebased version of Code
This commit is contained in:
parent
d83c9f194f
commit
e70e2b8ecc
@ -86,7 +86,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
|
|||||||
a_Info[E_BLOCK_ENDER_CHEST ].m_SpreadLightFalloff = 1;
|
a_Info[E_BLOCK_ENDER_CHEST ].m_SpreadLightFalloff = 1;
|
||||||
a_Info[E_BLOCK_END_PORTAL ].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_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 ].m_SpreadLightFalloff = 1;
|
||||||
a_Info[E_BLOCK_FENCE_GATE ].m_SpreadLightFalloff = 1;
|
a_Info[E_BLOCK_FENCE_GATE ].m_SpreadLightFalloff = 1;
|
||||||
a_Info[E_BLOCK_FIRE ].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));
|
a_Pickups.push_back(cItem(E_ITEM_BED, 1, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool CanDirtGrowGrass(NIBBLETYPE a_Meta) override
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Bed specific helper functions
|
// Bed specific helper functions
|
||||||
static NIBBLETYPE RotationToMetaData(double a_Rotation)
|
static NIBBLETYPE RotationToMetaData(double a_Rotation)
|
||||||
|
@ -39,19 +39,6 @@ public:
|
|||||||
{
|
{
|
||||||
return;
|
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
|
// Make sure that there is enough light at the source block to spread
|
||||||
if (!a_Chunk.GetWorld()->IsChunkLighted(a_Chunk.GetPosX(), a_Chunk.GetPosZ()))
|
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());
|
a_Chunk.GetWorld()->QueueLightChunk(a_Chunk.GetPosX(), a_Chunk.GetPosZ());
|
||||||
return;
|
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
|
// Source block is not bright enough to spread
|
||||||
return;
|
if (light < 9)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grass spreads to adjacent dirt blocks:
|
// Grass spreads to adjacent dirt blocks:
|
||||||
@ -96,10 +94,9 @@ public:
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
BLOCKTYPE AboveDest;
|
NIBBLETYPE light = std::max(a_Chunk.GetBlockLight(BlockX, BlockY + 1, BlockZ), a_Chunk.GetTimeAlteredLight(a_Chunk.GetSkyLight(BlockX, BlockY + 1, BlockZ)));
|
||||||
NIBBLETYPE AboveMeta;
|
// Grass does not spread to blocks with a light level less than 5
|
||||||
Chunk->GetBlockTypeMeta(BlockX, BlockY + 1, BlockZ, AboveDest, AboveMeta);
|
if (light > 4)
|
||||||
if (cBlockInfo::GetHandler(AboveDest)->CanDirtGrowGrass(AboveMeta))
|
|
||||||
{
|
{
|
||||||
if (!cRoot::Get()->GetPluginManager()->CallHookBlockSpread(*Chunk->GetWorld(), Chunk->GetPosX() * cChunkDef::Width + BlockX, BlockY, Chunk->GetPosZ() * cChunkDef::Width + BlockZ, ssGrassSpread))
|
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);
|
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()
|
bool cBlockHandler::IsUseable()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -83,9 +83,6 @@ public:
|
|||||||
|
|
||||||
/// Checks if the block can stay at the specified relative coords in the chunk
|
/// 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);
|
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.
|
/** Checks if the block can be placed at this point.
|
||||||
Default: CanBeAt(...)
|
Default: CanBeAt(...)
|
||||||
|
@ -88,12 +88,6 @@ public:
|
|||||||
return true;
|
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
|
/// Returns true if the specified blocktype is one of the slabs handled by this handler
|
||||||
static bool IsAnySlabType(BLOCKTYPE a_BlockType)
|
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)
|
static NIBBLETYPE RotationToMetaData(double a_Rotation)
|
||||||
{
|
{
|
||||||
a_Rotation += 90 + 45; // So its not aligned with axis
|
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()
|
bool cBlockHandler::IsUseable()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user