summaryrefslogtreecommitdiffstats
path: root/source/Entities/Entity.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Entities/Entity.cpp')
-rw-r--r--source/Entities/Entity.cpp41
1 files changed, 23 insertions, 18 deletions
diff --git a/source/Entities/Entity.cpp b/source/Entities/Entity.cpp
index d884fe51c..3a93b7519 100644
--- a/source/Entities/Entity.cpp
+++ b/source/Entities/Entity.cpp
@@ -520,31 +520,36 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
// Push out entity.
BLOCKTYPE GotBlock;
- static const Vector3i CrossCoords[] =
+ static const struct
{
- Vector3i(1, 0, 0),
- Vector3i(-1, 0, 0),
- Vector3i(0, 0, 1),
- Vector3i(0, 0, -1),
+ int x, y, z;
+ } gCrossCoords[] =
+ {
+ { 1, 0, 0},
+ {-1, 0, 0},
+ { 0, 0, 1},
+ { 0, 0, -1},
} ;
- Vector3i PushDirection(0, 1, 0);
-
- for (int i = 0; i < ARRAYCOUNT(CrossCoords); i++)
+
+ bool IsNoAirSurrounding = true;
+ for (int i = 0; i < ARRAYCOUNT(gCrossCoords); i++)
{
- NextChunk->UnboundedRelGetBlockType(RelBlockX + CrossCoords[i].x, BlockY, RelBlockZ + CrossCoords[i].z, GotBlock);
- if (!g_BlockIsSolid[GotBlock])
- {
- PushDirection = CrossCoords[i];
- break;
- }
- } // for i - CrossCoords[]
- NextPos += Vector3d(PushDirection) * 0.2;
+ NextChunk->UnboundedRelGetBlockType(RelBlockX + gCrossCoords[i].x, BlockY, RelBlockZ + gCrossCoords[i].z, GotBlock);
+ if (!g_BlockIsSolid[GotBlock])
+ {
+ NextPos.x += gCrossCoords[i].x;
+ NextPos.z += gCrossCoords[i].z;
+ IsNoAirSurrounding = false;
+ }
+ } // for i - gCrossCoords[]
+ if (IsNoAirSurrounding)
+ { NextPos.y += 0.5; }
+
m_bOnGround = true;
LOGD("Entity #%d (%s) is inside a block at {%d,%d,%d}",
- m_UniqueID, GetClass(), BlockX, BlockY,
- );
+ m_UniqueID, GetClass(), BlockX, BlockY, BlockZ);
}
if (!m_bOnGround)