summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2016-04-18 20:58:57 +0200
committerLogicParrot <LogicParrot@users.noreply.github.com>2016-04-18 20:58:57 +0200
commit250e50c01e5ef9ed6eb8ec77f495f0150a8d5c32 (patch)
tree3e7de5a5d1187baf2d714bd815b09d16ea0bdf67 /src/Mobs
parentMerge pull request #3146 from LogicParrot/snowFix (diff)
downloadcuberite-250e50c01e5ef9ed6eb8ec77f495f0150a8d5c32.tar
cuberite-250e50c01e5ef9ed6eb8ec77f495f0150a8d5c32.tar.gz
cuberite-250e50c01e5ef9ed6eb8ec77f495f0150a8d5c32.tar.bz2
cuberite-250e50c01e5ef9ed6eb8ec77f495f0150a8d5c32.tar.lz
cuberite-250e50c01e5ef9ed6eb8ec77f495f0150a8d5c32.tar.xz
cuberite-250e50c01e5ef9ed6eb8ec77f495f0150a8d5c32.tar.zst
cuberite-250e50c01e5ef9ed6eb8ec77f495f0150a8d5c32.zip
Diffstat (limited to '')
-rw-r--r--src/Mobs/Monster.cpp10
-rw-r--r--src/Mobs/PathFinder.cpp10
2 files changed, 15 insertions, 5 deletions
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index a4cb9e63f..3b0fdd36c 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -667,10 +667,14 @@ void cMonster::InStateIdle(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
NIBBLETYPE BlockMeta;
int RelX = static_cast<int>(Destination.x) - Chunk->GetPosX() * cChunkDef::Width;
int RelZ = static_cast<int>(Destination.z) - Chunk->GetPosZ() * cChunkDef::Width;
- Chunk->GetBlockTypeMeta(RelX, static_cast<int>(Destination.y) - 1, RelZ, BlockType, BlockMeta);
- if (BlockType != E_BLOCK_STATIONARY_WATER) // Idle mobs shouldn't enter water on purpose
+ int YBelowUs = static_cast<int>(Destination.y) - 1;
+ if (YBelowUs >= 0)
{
- MoveToPosition(Destination);
+ Chunk->GetBlockTypeMeta(RelX, YBelowUs, RelZ, BlockType, BlockMeta);
+ if (BlockType != E_BLOCK_STATIONARY_WATER) // Idle mobs shouldn't enter water on purpose
+ {
+ MoveToPosition(Destination);
+ }
}
}
}
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;