diff options
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java')
-rw-r--r-- | src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java index d1303675..35f26c0e 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java @@ -106,7 +106,7 @@ public class CrystalsHud { //position, scale and rotate the player marker matrices.translate(renderX, renderY, 0f); matrices.scale(0.75f, 0.75f, 0f); - matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(playerRotation + 180f), 2, 3, 0); + matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(yaw2Cardinal(playerRotation)), 2, 3, 0); //draw marker on map context.drawTexture(MAP_ICON, 0, 0, 2, 0, 5, 7, 128, 128); @@ -133,6 +133,18 @@ public class CrystalsHud { } /** + * Converts yaw to the cardinal directions that a player marker can be rotated towards on a map. + * The rotations of a marker follow this order: N, NNE, NE, ENE, E, ESE, SE, SSE, S, SSW, SW, WSW, W, WNW, NW, NNW. + * <br><br> + * Based off code from {@link net.minecraft.client.render.MapRenderer} + */ + private static float yaw2Cardinal(float yaw) { + byte clipped = (byte)((yaw += yaw < 0.0 ? -8.0 : 8.0) * 16.0 / 360.0); + + return (clipped * 360f) / 16f; + } + + /** * Works out if the crystals map should be rendered and sets {@link CrystalsHud#visible} accordingly. * */ |