3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-26 19:02:36 +01:00

Use Location.getYaw() and getPitch() for converting to Bukkit Locations.

Dieser Commit ist enthalten in:
sk89q 2014-07-13 21:25:28 -07:00
Ursprung bdd6d20013
Commit f50c69ee8f

Datei anzeigen

@ -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()));
} }
/** /**