summaryrefslogtreecommitdiffstats
path: root/source/FallingBlock.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-04-13 23:02:10 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-04-13 23:02:10 +0200
commita49c004278b0e300521e9cedf44a46ac843a958b (patch)
treecc268ccbd5b938be93923d9aced847572364e263 /source/FallingBlock.cpp
parentFixed a bit of coding style and function names in cItem (diff)
downloadcuberite-a49c004278b0e300521e9cedf44a46ac843a958b.tar
cuberite-a49c004278b0e300521e9cedf44a46ac843a958b.tar.gz
cuberite-a49c004278b0e300521e9cedf44a46ac843a958b.tar.bz2
cuberite-a49c004278b0e300521e9cedf44a46ac843a958b.tar.lz
cuberite-a49c004278b0e300521e9cedf44a46ac843a958b.tar.xz
cuberite-a49c004278b0e300521e9cedf44a46ac843a958b.tar.zst
cuberite-a49c004278b0e300521e9cedf44a46ac843a958b.zip
Diffstat (limited to '')
-rw-r--r--source/FallingBlock.cpp44
1 files changed, 24 insertions, 20 deletions
diff --git a/source/FallingBlock.cpp b/source/FallingBlock.cpp
index 5edae6283..db5679454 100644
--- a/source/FallingBlock.cpp
+++ b/source/FallingBlock.cpp
@@ -4,6 +4,7 @@
#include "World.h"
#include "ClientHandle.h"
#include "Simulator/SandSimulator.h"
+#include "Chunk.h"
@@ -40,7 +41,7 @@ void cFallingBlock::SpawnOn(cClientHandle & a_ClientHandle)
-void cFallingBlock::Tick(float a_Dt, MTRand & a_TickRandom)
+void cFallingBlock::Tick(float a_Dt, cChunk & a_Chunk)
{
float MilliDt = a_Dt * 0.001f;
AddSpeedY(MilliDt * -9.8f);
@@ -62,26 +63,29 @@ void cFallingBlock::Tick(float a_Dt, MTRand & a_TickRandom)
return;
}
- if (BlockY < cChunkDef::Height - 1)
+ if (BlockY >= cChunkDef::Height)
{
- BLOCKTYPE BlockBelow;
- NIBBLETYPE BelowMeta;
- GetWorld()->GetBlockTypeMeta(BlockX, BlockY, BlockZ, BlockBelow, BelowMeta);
- if (cSandSimulator::DoesBreakFallingThrough(BlockBelow, BelowMeta))
- {
- // Fallen onto a block that breaks this into pickups (e. g. half-slab)
- // Must finish the fall with coords one below the block:
- cSandSimulator::FinishFalling(m_World, BlockX, BlockY, BlockZ, m_BlockType, m_BlockMeta);
- Destroy();
- return;
- }
- else if (!cSandSimulator::CanContinueFallThrough(BlockBelow))
- {
- // Fallen onto a solid block
- cSandSimulator::FinishFalling(m_World, BlockX, BlockY + 1, BlockZ, m_BlockType, m_BlockMeta);
- Destroy();
- return;
- }
+ // Above the world, just wait for it to fall back down
+ return;
+ }
+
+ int idx = a_Chunk.MakeIndexNoCheck(BlockX - a_Chunk.GetPosX() * cChunkDef::Width, BlockY, BlockZ - a_Chunk.GetPosZ() * cChunkDef::Width);
+ BLOCKTYPE BlockBelow = a_Chunk.GetBlock(idx);
+ NIBBLETYPE BelowMeta = a_Chunk.GetMeta(idx);
+ if (cSandSimulator::DoesBreakFallingThrough(BlockBelow, BelowMeta))
+ {
+ // Fallen onto a block that breaks this into pickups (e. g. half-slab)
+ // Must finish the fall with coords one below the block:
+ cSandSimulator::FinishFalling(m_World, BlockX, BlockY, BlockZ, m_BlockType, m_BlockMeta);
+ Destroy();
+ return;
+ }
+ else if (!cSandSimulator::CanContinueFallThrough(BlockBelow))
+ {
+ // Fallen onto a solid block
+ cSandSimulator::FinishFalling(m_World, BlockX, BlockY + 1, BlockZ, m_BlockType, m_BlockMeta);
+ Destroy();
+ return;
}
}