summaryrefslogtreecommitdiffstats
path: root/source/Simulator
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-03-02 21:24:18 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-03-02 21:24:18 +0100
commit86c97cb28a2f21cff026497cc11f15eeb3cfafb0 (patch)
treecd18ff1225db4d50577e72115ca3a32c07db0f37 /source/Simulator
parentRewritten SandSimulator to use direct chunk access; and sand falling on torches now creates a pickup. (diff)
downloadcuberite-86c97cb28a2f21cff026497cc11f15eeb3cfafb0.tar
cuberite-86c97cb28a2f21cff026497cc11f15eeb3cfafb0.tar.gz
cuberite-86c97cb28a2f21cff026497cc11f15eeb3cfafb0.tar.bz2
cuberite-86c97cb28a2f21cff026497cc11f15eeb3cfafb0.tar.lz
cuberite-86c97cb28a2f21cff026497cc11f15eeb3cfafb0.tar.xz
cuberite-86c97cb28a2f21cff026497cc11f15eeb3cfafb0.tar.zst
cuberite-86c97cb28a2f21cff026497cc11f15eeb3cfafb0.zip
Diffstat (limited to '')
-rw-r--r--source/Simulator/SandSimulator.cpp28
1 files changed, 27 insertions, 1 deletions
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
}