diff options
author | snowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb> | 2011-04-10 20:09:04 +0000 |
---|---|---|
committer | snowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb> | 2011-04-10 20:09:04 +0000 |
commit | c8c019660e1a2e6fadebeb46f74a00a95fda07ea (patch) | |
tree | 2717ca2783fc96db0cad805724e54274d0e6cb90 | |
parent | 017e2082314927756488db93c9279e19dc8bd5df (diff) | |
download | Essentials-c8c019660e1a2e6fadebeb46f74a00a95fda07ea.tar Essentials-c8c019660e1a2e6fadebeb46f74a00a95fda07ea.tar.gz Essentials-c8c019660e1a2e6fadebeb46f74a00a95fda07ea.tar.lz Essentials-c8c019660e1a2e6fadebeb46f74a00a95fda07ea.tar.xz Essentials-c8c019660e1a2e6fadebeb46f74a00a95fda07ea.zip |
[trunk] getSaveDestination: round location and center the player on the block
Less chance to get stuck in walls
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1166 e251c2fe-e539-e718-e476-b85c1f46cddb
-rw-r--r-- | Essentials/src/com/earth2me/essentials/PlayerExtension.java | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Essentials/src/com/earth2me/essentials/PlayerExtension.java b/Essentials/src/com/earth2me/essentials/PlayerExtension.java index 758f8076d..8819f9e08 100644 --- a/Essentials/src/com/earth2me/essentials/PlayerExtension.java +++ b/Essentials/src/com/earth2me/essentials/PlayerExtension.java @@ -28,8 +28,10 @@ public class PlayerExtension extends PlayerWrapper public float getCorrectedYaw() { - float angle = (getLocation().getYaw() - 90) % 360; - if (angle < 0) angle += 360.0F; + float angle = (getLocation().getYaw() - 90.0f) % 360.0f; + if (angle < 0) { + angle += 360.0f; + } return angle; } @@ -46,14 +48,14 @@ public class PlayerExtension extends PlayerWrapper public Location getSafeDestination(Location loc) throws Exception { World world = loc.getWorld(); - double x = loc.getX(); - double y = loc.getY(); - double z = loc.getZ(); + double x = Math.round(loc.getX())+0.5; + double y = Math.round(loc.getY()); + double z = Math.round(loc.getZ())+0.5; while (isBlockAboveAir(world, x, y, z)) { y -= 1.0D; - if (y < 0) { + if (y < 0.0D) { throw new Exception("Hole in floor"); } } @@ -131,7 +133,7 @@ public class PlayerExtension extends PlayerWrapper public EntityPlayer getHandle() { - return (EntityPlayer)getCraftPlayer().getHandle(); + return getCraftPlayer().getHandle(); } public CraftPlayer getCraftPlayer() |