diff --git a/Essentials/src/main/java/com/earth2me/essentials/utils/LocationUtil.java b/Essentials/src/main/java/com/earth2me/essentials/utils/LocationUtil.java index f9eb69c20cd..b8fceb3a1eb 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/utils/LocationUtil.java +++ b/Essentials/src/main/java/com/earth2me/essentials/utils/LocationUtil.java @@ -125,6 +125,13 @@ public static boolean isBlockOutsideWorldBorder(final World world, final int x, return x < x1 || x > x2 || z < z1 || z > z2; } + public static boolean isAboveNetherRoof(final World world, final int x, final int y, final int z) { + if (world.getEnvironment() != World.Environment.NETHER) { + return false; + } + return y >= world.getHighestBlockYAt(x, z); + } + public static int getXInsideWorldBorder(final World world, final int x) { final Location center = world.getWorldBorder().getCenter(); final int radius = (int) world.getWorldBorder().getSize() / 2; @@ -277,6 +284,9 @@ public static Location getSafeDestination(IEssentials ess, final Location loc) t } } } + if (isAboveNetherRoof(world, x, y, z)) { + y = world.getHighestBlockYAt(x, z) - 1; + } return new Location(world, x + 0.5, y, z + 0.5, loc.getYaw(), loc.getPitch()); }