mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-10-04 07:44:29 +00:00
[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
This commit is contained in:
parent
017e208231
commit
c8c019660e
|
@ -28,8 +28,10 @@ public class PlayerExtension extends PlayerWrapper
|
||||||
|
|
||||||
public float getCorrectedYaw()
|
public float getCorrectedYaw()
|
||||||
{
|
{
|
||||||
float angle = (getLocation().getYaw() - 90) % 360;
|
float angle = (getLocation().getYaw() - 90.0f) % 360.0f;
|
||||||
if (angle < 0) angle += 360.0F;
|
if (angle < 0) {
|
||||||
|
angle += 360.0f;
|
||||||
|
}
|
||||||
return angle;
|
return angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,14 +48,14 @@ public class PlayerExtension extends PlayerWrapper
|
||||||
public Location getSafeDestination(Location loc) throws Exception
|
public Location getSafeDestination(Location loc) throws Exception
|
||||||
{
|
{
|
||||||
World world = loc.getWorld();
|
World world = loc.getWorld();
|
||||||
double x = loc.getX();
|
double x = Math.round(loc.getX())+0.5;
|
||||||
double y = loc.getY();
|
double y = Math.round(loc.getY());
|
||||||
double z = loc.getZ();
|
double z = Math.round(loc.getZ())+0.5;
|
||||||
|
|
||||||
while (isBlockAboveAir(world, x, y, z))
|
while (isBlockAboveAir(world, x, y, z))
|
||||||
{
|
{
|
||||||
y -= 1.0D;
|
y -= 1.0D;
|
||||||
if (y < 0) {
|
if (y < 0.0D) {
|
||||||
throw new Exception("Hole in floor");
|
throw new Exception("Hole in floor");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,7 +133,7 @@ public class PlayerExtension extends PlayerWrapper
|
||||||
|
|
||||||
public EntityPlayer getHandle()
|
public EntityPlayer getHandle()
|
||||||
{
|
{
|
||||||
return (EntityPlayer)getCraftPlayer().getHandle();
|
return getCraftPlayer().getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CraftPlayer getCraftPlayer()
|
public CraftPlayer getCraftPlayer()
|
||||||
|
|
Loading…
Reference in a new issue