summaryrefslogtreecommitdiffstats
path: root/source/FallingBlock.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-03-02 20:57:09 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-03-02 20:57:09 +0100
commit6744738a85c60238585dcf72af211f852fd7e4c6 (patch)
tree47f36786b377a69097dc479ea9ab8991b35eb9d5 /source/FallingBlock.cpp
parentAdded the anvil block (diff)
downloadcuberite-6744738a85c60238585dcf72af211f852fd7e4c6.tar
cuberite-6744738a85c60238585dcf72af211f852fd7e4c6.tar.gz
cuberite-6744738a85c60238585dcf72af211f852fd7e4c6.tar.bz2
cuberite-6744738a85c60238585dcf72af211f852fd7e4c6.tar.lz
cuberite-6744738a85c60238585dcf72af211f852fd7e4c6.tar.xz
cuberite-6744738a85c60238585dcf72af211f852fd7e4c6.tar.zst
cuberite-6744738a85c60238585dcf72af211f852fd7e4c6.zip
Diffstat (limited to 'source/FallingBlock.cpp')
-rw-r--r--source/FallingBlock.cpp45
1 files changed, 34 insertions, 11 deletions
diff --git a/source/FallingBlock.cpp b/source/FallingBlock.cpp
index 8f0320d9b..12362009d 100644
--- a/source/FallingBlock.cpp
+++ b/source/FallingBlock.cpp
@@ -3,15 +3,17 @@
#include "FallingBlock.h"
#include "World.h"
#include "ClientHandle.h"
+#include "Simulator/SandSimulator.h"
-cFallingBlock::cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType)
- : super(etFallingBlock, a_BlockPosition.x + 0.5f, a_BlockPosition.y + 0.5f, a_BlockPosition.z + 0.5f)
- , m_BlockType(a_BlockType)
- , m_OriginalPosition(a_BlockPosition)
+cFallingBlock::cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) :
+ super(etFallingBlock, a_BlockPosition.x + 0.5f, a_BlockPosition.y + 0.5f, a_BlockPosition.z + 0.5f),
+ m_BlockType(a_BlockType),
+ m_BlockMeta(a_BlockMeta),
+ m_OriginalPosition(a_BlockPosition)
{
}
@@ -21,7 +23,7 @@ cFallingBlock::cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_Block
void cFallingBlock::Initialize(cWorld * a_World)
{
- super::Initialize( a_World );
+ super::Initialize(a_World);
a_World->BroadcastSpawn(*this);
}
@@ -44,13 +46,34 @@ void cFallingBlock::Tick(float a_Dt, MTRand & a_TickRandom)
m_Speed.y -= MilliDt * 9.8f;
m_Pos.y += m_Speed.y * MilliDt;
- // GetWorld()->BroadcastTeleportEntity(*this); // Testing position
-
- Vector3i BlockPos( m_OriginalPosition.x, (int)(m_Pos.y - 0.5), m_OriginalPosition.z);
- if (!IsPassable(GetWorld()->GetBlock(BlockPos)))
+ // GetWorld()->BroadcastTeleportEntity(*this); // Test position
+
+ int BlockX = (int)m_OriginalPosition.x;
+ int BlockY = (int)(m_Pos.y - 0.5);
+ int BlockZ = (int)m_OriginalPosition.z;
+
+ if (BlockY < 0)
+ {
+ // Fallen out of this world, just continue falling until out of sight, then destroy:
+ if (BlockY < 100)
+ {
+ Destroy();
+ }
+ return;
+ }
+
+ if (BlockY < cChunkDef::Height - 1)
{
- Destroy();
- GetWorld()->SetBlock(BlockPos.x, BlockPos.y + 1, BlockPos.z, m_BlockType, 0);
+ BLOCKTYPE BlockBelow = GetWorld()->GetBlock(BlockX, BlockY, BlockZ);
+ if (
+ cSandSimulator::DoesBreakFallingThrough(BlockBelow) || // Fallen onto a block that breaks this into pickups (e. g. half-slab)
+ !cSandSimulator::CanContinueFallThrough(BlockBelow) // Fallen onto a solid block
+ )
+ {
+ cSandSimulator::FinishFalling(m_World, BlockX, BlockY + 1, BlockZ, m_BlockType, m_BlockMeta);
+ Destroy();
+ return;
+ }
}
}