mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-07 07:32:03 -07:00
Added Entity#setRotation.
Unlike Entity#teleport this can also be used while the entity is inside a vehicle. By: blablubbabc <lukas@wirsindwir.de>
This commit is contained in:
@@ -633,4 +633,39 @@ public class Location implements Cloneable, ConfigurationSerializable {
|
||||
|
||||
return new Location(world, NumberConversions.toDouble(args.get("x")), NumberConversions.toDouble(args.get("y")), NumberConversions.toDouble(args.get("z")), NumberConversions.toFloat(args.get("yaw")), NumberConversions.toFloat(args.get("pitch")));
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes the given yaw angle to a value between <code>+/-180</code>
|
||||
* degrees.
|
||||
*
|
||||
* @param yaw the yaw in degrees
|
||||
* @return the normalized yaw in degrees
|
||||
* @see Location#getYaw()
|
||||
*/
|
||||
public static float normalizeYaw(float yaw) {
|
||||
yaw %= 360.0f;
|
||||
if (yaw >= 180.0f) {
|
||||
yaw -= 360.0f;
|
||||
} else if (yaw < -180.0f) {
|
||||
yaw += 360.0f;
|
||||
}
|
||||
return yaw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes the given pitch angle to a value between <code>+/-90</code>
|
||||
* degrees.
|
||||
*
|
||||
* @param pitch the pitch in degrees
|
||||
* @return the normalized pitch in degrees
|
||||
* @see Location#getPitch()
|
||||
*/
|
||||
public static float normalizePitch(float pitch) {
|
||||
if (pitch > 90.0f) {
|
||||
pitch = 90.0f;
|
||||
} else if (pitch < -90.0f) {
|
||||
pitch = -90.0f;
|
||||
}
|
||||
return pitch;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user