mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-27 10:31:51 +01:00
Fix issue when finding direction with MathUtils when yaw < 0
This commit is contained in:
parent
7eee0c788f
commit
9e7f05c311
@ -30,7 +30,7 @@ public class MathUtils {
|
|||||||
|
|
||||||
public static Direction getHorizontalDirection(float yawInDegrees) {
|
public static Direction getHorizontalDirection(float yawInDegrees) {
|
||||||
// +45f gives a 90° angle for the direction (-1° and 1° are towards the same direction)
|
// +45f gives a 90° angle for the direction (-1° and 1° are towards the same direction)
|
||||||
int directionIndex = (int) ((yawInDegrees+45f) / 90f);
|
int directionIndex = (int) Math.floor(((yawInDegrees+45f) / 90f));
|
||||||
if(directionIndex < 0) {
|
if(directionIndex < 0) {
|
||||||
directionIndex = Direction.HORIZONTAL.length-directionIndex;
|
directionIndex = Direction.HORIZONTAL.length-directionIndex;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user