From 0a82274e840dfee77a762297e1c9bd5e44969f47 Mon Sep 17 00:00:00 2001 From: Erica Marigold Date: Fri, 16 Aug 2024 16:24:33 +0530 Subject: [PATCH] feat: handle left-handed UI case --- .../devcomp/elytralock/events/HudRenderHandler.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/xyz/devcomp/elytralock/events/HudRenderHandler.java b/src/main/java/xyz/devcomp/elytralock/events/HudRenderHandler.java index a6688ed..b627850 100644 --- a/src/main/java/xyz/devcomp/elytralock/events/HudRenderHandler.java +++ b/src/main/java/xyz/devcomp/elytralock/events/HudRenderHandler.java @@ -7,6 +7,7 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.render.RenderTickCounter; import net.minecraft.client.util.Window; +import net.minecraft.util.Arm; import net.minecraft.util.Identifier; public class HudRenderHandler implements HudRenderCallback { @@ -18,12 +19,19 @@ public class HudRenderHandler implements HudRenderCallback { if (!MinecraftClient.isHudEnabled()) return; + int offset = switch (ElytraLock.client.player.getMainArm()) { + case Arm.RIGHT: + yield 95; + case Arm.LEFT: + yield -115; + }; + Identifier icon = Identifier.of("elytra-lock", "textures/gui/" + (ElytraLock.isLocked() ? "locked" : "unlocked") + ".png"); Window window = ElytraLock.client.getWindow(); int width = window.getScaledWidth(), height = window.getScaledHeight(); - context.drawTexture(icon, (width / 2) + 95, height - HEIGHT - 3, 0, 0, WIDTH, HEIGHT, WIDTH, HEIGHT); + context.drawTexture(icon, (width / 2) + offset, height - HEIGHT - 3, 0, 0, WIDTH, HEIGHT, WIDTH, HEIGHT); } } \ No newline at end of file