1
0

cSandSimulator: implemented InstantFall

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1241 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2013-03-02 20:24:18 +00:00
parent 6744738a85
commit 86c97cb28a

View File

@ -246,7 +246,33 @@ void cSandSimulator::FinishFalling(
void cSandSimulator::DoInstantFall(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ)
{
// TODO
// Remove the original block:
BLOCKTYPE FallingBlockType;
NIBBLETYPE FallingBlockMeta;
a_Chunk->GetBlockTypeMeta(a_RelX, a_RelY, a_RelZ, FallingBlockType, FallingBlockMeta);
a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_AIR, 0);
// Search for a place to put it:
for (int y = a_RelY - 1; y >= 0; y--)
{
BLOCKTYPE BlockType = a_Chunk->GetBlock(a_RelX, y, a_RelZ);
if (
!DoesBreakFallingThrough(BlockType) &&
CanContinueFallThrough(BlockType)
)
{
// Can fall further down
continue;
}
// Finish the fall at the found bottom:
int BlockX = a_RelX + a_Chunk->GetPosX() * cChunkDef::Width;
int BlockZ = a_RelZ + a_Chunk->GetPosZ() * cChunkDef::Width;
FinishFalling(&m_World, BlockX, y + 1, BlockZ, FallingBlockType, FallingBlockMeta);
return;
}
// The block just "fell off the world" without leaving a trace
}