From 86c97cb28a2f21cff026497cc11f15eeb3cfafb0 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sat, 2 Mar 2013 20:24:18 +0000 Subject: cSandSimulator: implemented InstantFall git-svn-id: http://mc-server.googlecode.com/svn/trunk@1241 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Simulator/SandSimulator.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/Simulator/SandSimulator.cpp b/source/Simulator/SandSimulator.cpp index 27e137354..84646a10a 100644 --- a/source/Simulator/SandSimulator.cpp +++ b/source/Simulator/SandSimulator.cpp @@ -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 } -- cgit v1.2.3