summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSafwatHalaby <SafwatHalaby@users.noreply.github.com>2015-05-30 09:50:04 +0200
committerSafwatHalaby <SafwatHalaby@users.noreply.github.com>2015-05-30 09:50:04 +0200
commitd9f5d3c85897cb1b2adfcd86c52d9a0378909132 (patch)
treef57f0ee40f611dcd2170ee2179b61dbfe719fae0
parentFix Destroy() calling behaviour (diff)
downloadcuberite-d9f5d3c85897cb1b2adfcd86c52d9a0378909132.tar
cuberite-d9f5d3c85897cb1b2adfcd86c52d9a0378909132.tar.gz
cuberite-d9f5d3c85897cb1b2adfcd86c52d9a0378909132.tar.bz2
cuberite-d9f5d3c85897cb1b2adfcd86c52d9a0378909132.tar.lz
cuberite-d9f5d3c85897cb1b2adfcd86c52d9a0378909132.tar.xz
cuberite-d9f5d3c85897cb1b2adfcd86c52d9a0378909132.tar.zst
cuberite-d9f5d3c85897cb1b2adfcd86c52d9a0378909132.zip
-rw-r--r--src/Mobs/Path.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/Mobs/Path.cpp b/src/Mobs/Path.cpp
index 1848e144e..c21eb597c 100644
--- a/src/Mobs/Path.cpp
+++ b/src/Mobs/Path.cpp
@@ -216,28 +216,35 @@ bool cPath::Step_Internal()
ProcessIfWalkable(CurrentCell->m_Location + Vector3i(0, 0, -1), CurrentCell, 10);
// Check diagonals on XY plane.
+ // x = -1: west, x = 1: east.
for (int x = -1; x <= 1; x += 2)
{
if (GetCell(CurrentCell->m_Location + Vector3i(x, 0, 0))->m_IsSolid) // If there's a solid our east / west.
{
- ProcessIfWalkable(CurrentCell->m_Location + Vector3i(x, 1, 0), CurrentCell, JUMP_G_COST); // Check east / west-up.
+ if (!GetCell(CurrentCell->m_Location + Vector3i(0, 1, 0))->m_IsSolid) // If there isn't a solid above.
+ {
+ ProcessIfWalkable(CurrentCell->m_Location + Vector3i(x, 1, 0), CurrentCell, JUMP_G_COST); // Check east-up / west-up.
+ }
}
else
{
- ProcessIfWalkable(CurrentCell->m_Location + Vector3i(x, -1, 0), CurrentCell, 14); // Else check east / west-down.
+ ProcessIfWalkable(CurrentCell->m_Location + Vector3i(x, -1, 0), CurrentCell, 14); // Else check east-down / west-down.
}
}
// Check diagonals on the YZ plane.
for (int z = -1; z <= 1; z += 2)
{
- if (GetCell(CurrentCell->m_Location + Vector3i(0, 0, z))->m_IsSolid) // If there's a solid our east / west.
+ if (GetCell(CurrentCell->m_Location + Vector3i(0, 0, z))->m_IsSolid) // If there's a solid our north / south.
{
- ProcessIfWalkable(CurrentCell->m_Location + Vector3i(0, 1, z), CurrentCell, JUMP_G_COST); // Check east / west-up.
+ if (!GetCell(CurrentCell->m_Location + Vector3i(0, 1, 0))->m_IsSolid) // If there isn't a solid above.
+ {
+ ProcessIfWalkable(CurrentCell->m_Location + Vector3i(0, 1, z), CurrentCell, JUMP_G_COST); // Check north-up / south-up.
+ }
}
else
{
- ProcessIfWalkable(CurrentCell->m_Location + Vector3i(0, -1, z), CurrentCell, 14); // Else check east / west-down.
+ ProcessIfWalkable(CurrentCell->m_Location + Vector3i(0, -1, z), CurrentCell, 14); // Else check north-down / south-down.
}
}