aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorAaron <51387595+AzureAaron@users.noreply.github.com>2024-02-03 06:13:42 -0500
committerAaron <51387595+AzureAaron@users.noreply.github.com>2024-02-03 06:13:42 -0500
commitebd53811b276b28bf4848846503c8c2a78104223 (patch)
tree8652f4355c20dd7fa772b12b3fbe165d6e72276c /src/main
parent9702d67ccf15f2bbb2c6a841efde5b71edb08395 (diff)
downloadSkyblocker-ebd53811b276b28bf4848846503c8c2a78104223.tar.gz
Skyblocker-ebd53811b276b28bf4848846503c8c2a78104223.tar.bz2
Skyblocker-ebd53811b276b28bf4848846503c8c2a78104223.zip
Vanilla-like marker rotation
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java14
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.
*
*/