feat: handle left-handed UI case

This commit is contained in:
Erica Marigold 2024-08-16 16:24:33 +05:30
parent 0a9d2105ef
commit 0a82274e84
No known key found for this signature in database
GPG key ID: 2768CC0C23D245D1

View file

@ -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);
}
}