mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-04-25 07:59:44 +00:00
Restore teleporting to middle of block, when flying and unsafe is enabled.
This commit is contained in:
parent
882ebae257
commit
016b39726c
2 changed files with 13 additions and 3 deletions
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -249,6 +249,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
|
||||
{
|
||||
if (loc.getWorld().equals(user.getBase().getWorld())
|
||||
|
@ -259,7 +269,7 @@ public class LocationUtil
|
|||
{
|
||||
user.getBase().setFlying(true);
|
||||
}
|
||||
return loc;
|
||||
return getRoundedDestination(loc);
|
||||
}
|
||||
return getSafeDestination(loc);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue