@@ -215,6 +215,10 @@ public static Location getTarget(final LivingEntity entity) throws Exception
215215
216216 static boolean isBlockAboveAir (final World world , final int x , final int y , final int z )
217217 {
218+ if (y > world .getMaxHeight ())
219+ {
220+ return true ;
221+ }
218222 return HOLLOW_MATERIALS .contains (world .getBlockAt (x , y - 1 , z ).getType ().getId ());
219223 }
220224
@@ -248,7 +252,7 @@ public static boolean isBlockDamaging(final World world, final int x, final int
248252 }
249253 return false ;
250254 }
251-
255+
252256 // Not needed if using getSafeDestination(loc)
253257 public static Location getRoundedDestination (final Location loc )
254258 {
@@ -273,7 +277,7 @@ public static Location getSafeDestination(final IUser user, final Location loc)
273277 }
274278 return getSafeDestination (loc );
275279 }
276-
280+
277281 public static Location getSafeDestination (final Location loc ) throws Exception
278282 {
279283 if (loc == null || loc .getWorld () == null )
@@ -347,15 +351,17 @@ public static boolean shouldFly(Location loc)
347351 final int x = loc .getBlockX ();
348352 int y = (int )Math .round (loc .getY ());
349353 final int z = loc .getBlockZ ();
354+ int count = 0 ;
350355 while (LocationUtil .isBlockUnsafe (world , x , y , z ) && y > -1 )
351356 {
352357 y --;
358+ count ++;
359+ if (count > 2 )
360+ {
361+ return true ;
362+ }
353363 }
354364
355- if (loc .getBlockY () - y > 1 || y < 0 )
356- {
357- return true ;
358- }
359- return false ;
365+ return y < 0 ? true : false ;
360366 }
361367}
0 commit comments