diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2013-09-13 20:54:50 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2013-09-13 20:54:50 +0200 |
commit | 47119b30270b0ea8e958bc64c38f27df47a9ae5d (patch) | |
tree | 59269a460ed53d0f867d42b6d27856968dae1ac0 | |
parent | Even more fixes [SEE DESC] (diff) | |
download | cuberite-47119b30270b0ea8e958bc64c38f27df47a9ae5d.tar cuberite-47119b30270b0ea8e958bc64c38f27df47a9ae5d.tar.gz cuberite-47119b30270b0ea8e958bc64c38f27df47a9ae5d.tar.bz2 cuberite-47119b30270b0ea8e958bc64c38f27df47a9ae5d.tar.lz cuberite-47119b30270b0ea8e958bc64c38f27df47a9ae5d.tar.xz cuberite-47119b30270b0ea8e958bc64c38f27df47a9ae5d.tar.zst cuberite-47119b30270b0ea8e958bc64c38f27df47a9ae5d.zip |
Diffstat (limited to '')
-rw-r--r-- | source/Entities/Entity.cpp | 41 |
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) |