diff options
author | KHobbits <rob@khobbits.co.uk> | 2014-02-02 16:43:31 +0000 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2014-02-02 16:43:31 +0000 |
commit | 016b39726ca6e03ddefa04a36d24a58d4f72f38d (patch) | |
tree | a22e0f45a59043abbf5def8919a427a292b60cb9 | |
parent | 882ebae257a7278e39b299c82827eb255f4799c7 (diff) | |
download | Essentials-016b39726ca6e03ddefa04a36d24a58d4f72f38d.tar Essentials-016b39726ca6e03ddefa04a36d24a58d4f72f38d.tar.gz Essentials-016b39726ca6e03ddefa04a36d24a58d4f72f38d.tar.lz Essentials-016b39726ca6e03ddefa04a36d24a58d4f72f38d.tar.xz Essentials-016b39726ca6e03ddefa04a36d24a58d4f72f38d.zip |
Restore teleporting to middle of block, when flying and unsafe is enabled.
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Teleport.java | 2 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/utils/LocationUtil.java | 14 |
2 files changed, 13 insertions, 3 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Teleport.java b/Essentials/src/com/earth2me/essentials/Teleport.java index 4d258156a..45e9a34e3 100644 --- a/Essentials/src/com/earth2me/essentials/Teleport.java +++ b/Essentials/src/com/earth2me/essentials/Teleport.java @@ -122,7 +122,7 @@ public class Teleport implements net.ess3.api.ITeleport { teleportee.getBase().leaveVehicle(); } - teleportee.getBase().teleport(loc); + teleportee.getBase().teleport(LocationUtil.getRoundedDestination(loc)); } } diff --git a/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java b/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java index 66a2ef581..b142ac3a9 100644 --- a/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java +++ b/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java @@ -248,6 +248,16 @@ public class LocationUtil } return false; } + + // Not needed if using getSafeDestination(loc) + public static Location getRoundedDestination(final Location loc) + { + final World world = loc.getWorld(); + int x = loc.getBlockX(); + int y = (int)Math.round(loc.getY()); + int z = loc.getBlockZ(); + return new Location(world, x + 0.5, y, z + 0.5, loc.getYaw(), loc.getPitch()); + } public static Location getSafeDestination(final IUser user, final Location loc) throws Exception { @@ -259,11 +269,11 @@ public class LocationUtil { user.getBase().setFlying(true); } - return loc; + return getRoundedDestination(loc); } return getSafeDestination(loc); } - + public static Location getSafeDestination(final Location loc) throws Exception { if (loc == null || loc.getWorld() == null) |