mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Use Location.getYaw() and getPitch() for converting to Bukkit Locations.
This commit is contained in:
parent
bdd6d20013
commit
f50c69ee8f
@ -91,16 +91,11 @@ final class BukkitAdapter {
|
|||||||
public static org.bukkit.Location adapt(Location location) {
|
public static org.bukkit.Location adapt(Location location) {
|
||||||
checkNotNull(location);
|
checkNotNull(location);
|
||||||
Vector position = location.toVector();
|
Vector position = location.toVector();
|
||||||
Vector direction = location.getDirection();
|
|
||||||
final double eyeX = direction.getX();
|
|
||||||
final double eyeZ = direction.getZ();
|
|
||||||
final float yaw = (float) Math.toDegrees(Math.atan2(-eyeX, eyeZ));
|
|
||||||
final double length = Math.sqrt(eyeX * eyeX + eyeZ * eyeZ);
|
|
||||||
final float pitch = (float) Math.toDegrees(Math.atan2(-direction.getY(), length));
|
|
||||||
return new org.bukkit.Location(
|
return new org.bukkit.Location(
|
||||||
adapt((World) location.getExtent()),
|
adapt((World) location.getExtent()),
|
||||||
position.getX(), position.getY(), position.getZ(),
|
position.getX(), position.getY(), position.getZ(),
|
||||||
yaw, pitch);
|
(float) Math.toDegrees(location.getYaw()),
|
||||||
|
(float) Math.toDegrees(location.getPitch()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user