diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2016-04-18 22:20:28 +0200 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2016-04-18 22:20:28 +0200 |
commit | 931ee84685b979a1b40e8078425600044ce86429 (patch) | |
tree | 3e7de5a5d1187baf2d714bd815b09d16ea0bdf67 /src/Mobs/PathFinder.cpp | |
parent | Merge pull request #3146 from LogicParrot/snowFix (diff) | |
parent | Fix issues below y = 0 (diff) | |
download | cuberite-931ee84685b979a1b40e8078425600044ce86429.tar cuberite-931ee84685b979a1b40e8078425600044ce86429.tar.gz cuberite-931ee84685b979a1b40e8078425600044ce86429.tar.bz2 cuberite-931ee84685b979a1b40e8078425600044ce86429.tar.lz cuberite-931ee84685b979a1b40e8078425600044ce86429.tar.xz cuberite-931ee84685b979a1b40e8078425600044ce86429.tar.zst cuberite-931ee84685b979a1b40e8078425600044ce86429.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Mobs/PathFinder.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Mobs/PathFinder.cpp b/src/Mobs/PathFinder.cpp index 4b6e70bbd..93664b596 100644 --- a/src/Mobs/PathFinder.cpp +++ b/src/Mobs/PathFinder.cpp @@ -196,7 +196,13 @@ bool cPathFinder::EnsureProperPoint(Vector3d & a_Vector, cChunk & a_Chunk) // If destination in the air, first try to go 1 block north, or east, or west. // This fixes the player leaning issue. // If that failed, we instead go down to the lowest air block. - Chunk->GetBlockTypeMeta(RelX, FloorC(a_Vector.y) - 1, RelZ, BlockType, BlockMeta); + int YBelowUs = FloorC(a_Vector.y) - 1; + if (YBelowUs < 0) + { + return false; + + } + Chunk->GetBlockTypeMeta(RelX, YBelowUs, RelZ, BlockType, BlockMeta); if (!(IsWaterOrSolid(BlockType))) { bool InTheAir = true; @@ -216,7 +222,7 @@ bool cPathFinder::EnsureProperPoint(Vector3d & a_Vector, cChunk & a_Chunk) } RelX = FloorC(a_Vector.x+x) - Chunk->GetPosX() * cChunkDef::Width; RelZ = FloorC(a_Vector.z+z) - Chunk->GetPosZ() * cChunkDef::Width; - Chunk->GetBlockTypeMeta(RelX, FloorC(a_Vector.y) - 1, RelZ, BlockType, BlockMeta); + Chunk->GetBlockTypeMeta(RelX, YBelowUs, RelZ, BlockType, BlockMeta); if (IsWaterOrSolid((BlockType))) { a_Vector.x += x; |