summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Monster.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-01-25 15:42:26 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-01-25 15:42:26 +0100
commit314fc3cdac702a44a257ada5fab52f0a7d37ffcd (patch)
treeb8fe855a3cd86841b16fba630dc7748d59a505fa /src/Mobs/Monster.h
parentAll mobs now drown (fixes #54) (diff)
downloadcuberite-314fc3cdac702a44a257ada5fab52f0a7d37ffcd.tar
cuberite-314fc3cdac702a44a257ada5fab52f0a7d37ffcd.tar.gz
cuberite-314fc3cdac702a44a257ada5fab52f0a7d37ffcd.tar.bz2
cuberite-314fc3cdac702a44a257ada5fab52f0a7d37ffcd.tar.lz
cuberite-314fc3cdac702a44a257ada5fab52f0a7d37ffcd.tar.xz
cuberite-314fc3cdac702a44a257ada5fab52f0a7d37ffcd.tar.zst
cuberite-314fc3cdac702a44a257ada5fab52f0a7d37ffcd.zip
Diffstat (limited to 'src/Mobs/Monster.h')
-rw-r--r--src/Mobs/Monster.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index c8129e63d..d04cb8941 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -168,10 +168,18 @@ protected:
If current Y is nonsolid, goes down to try to find a solid block, then returns that + 1
If current Y is solid, goes up to find first nonsolid block, and returns that */
int FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ);
- /** Returns if a monster can actually reach a given height by jumping */
+ /** Returns if a monster can actually reach a given height by jumping or walking */
inline bool IsNextYPosReachable(int a_PosY)
{
- return (a_PosY > (int)floor(GetPosY())) && (a_PosY == (int)floor(GetPosY()) + 1);
+ return (
+ (a_PosY <= (int)floor(GetPosY())) ||
+ DoesPosYRequireJump(a_PosY)
+ );
+ }
+ /** Returns if a monster can reach a given height by jumping */
+ inline bool DoesPosYRequireJump(int a_PosY)
+ {
+ return ((a_PosY > (int)floor(GetPosY())) && (a_PosY == (int)floor(GetPosY()) + 1));
}
/** A semi-temporary list to store the traversed coordinates during active pathfinding so we don't visit them again */