summaryrefslogtreecommitdiffstats
path: root/source/Entities
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2013-09-11 23:10:29 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2013-09-11 23:10:29 +0200
commita1d5d25525bec8ed7646e887a08bae48e84f9131 (patch)
tree07217304a3cf4334a7408a23f64915ed6e36a995 /source/Entities
parentFixed two bugs (diff)
downloadcuberite-a1d5d25525bec8ed7646e887a08bae48e84f9131.tar
cuberite-a1d5d25525bec8ed7646e887a08bae48e84f9131.tar.gz
cuberite-a1d5d25525bec8ed7646e887a08bae48e84f9131.tar.bz2
cuberite-a1d5d25525bec8ed7646e887a08bae48e84f9131.tar.lz
cuberite-a1d5d25525bec8ed7646e887a08bae48e84f9131.tar.xz
cuberite-a1d5d25525bec8ed7646e887a08bae48e84f9131.tar.zst
cuberite-a1d5d25525bec8ed7646e887a08bae48e84f9131.zip
Diffstat (limited to '')
-rw-r--r--source/Entities/Entity.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/source/Entities/Entity.cpp b/source/Entities/Entity.cpp
index b8596927f..3cb53a6c6 100644
--- a/source/Entities/Entity.cpp
+++ b/source/Entities/Entity.cpp
@@ -518,13 +518,30 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
else
{
// Push out entity.
+ BLOCKTYPE GotBlock;
- if (NextChunk->GetBlock( RelBlockX + 1, BlockY, RelBlockZ ) == E_BLOCK_AIR) { NextPos.x += 0.2; }
- else if (NextChunk->GetBlock( RelBlockX - 1, BlockY, RelBlockZ ) == E_BLOCK_AIR) { NextPos.x += -0.2; }
- else if (NextChunk->GetBlock( RelBlockX, BlockY, RelBlockZ + 1 ) == E_BLOCK_AIR) { NextPos.z += 0.2; }
- else if (NextChunk->GetBlock( RelBlockX, BlockY, RelBlockZ - 1 ) == E_BLOCK_AIR) { NextPos.z += -0.2; }
- else { NextPos.y += 0.2; }
+ static const struct
+ {
+ int x, y, z;
+ } gCrossCoords[] =
+ {
+ { 1, 0, 0},
+ {-1, 0, 0},
+ { 0, 0, 1},
+ { 0, 0, -1},
+ } ;
+ for (int i = 0; i < ARRAYCOUNT(gCrossCoords); i++)
+ {
+ NextChunk->UnboundedRelGetBlockType(RelBlockX + gCrossCoords[i].x, BlockY, RelBlockZ + gCrossCoords[i].z, GotBlock);
+ if (GotBlock == E_BLOCK_AIR)
+ {
+ NextPos.x += gCrossCoords[i].x;
+ NextPos.z += gCrossCoords[i].z;
+ }
+ else { NextPos.y += 0.2; }
+ } // for i - gCrossCoords[]
+
m_bOnGround = true;
LOGD("Entity #%d (%s) is inside a block at {%d,%d,%d}",