mirror of
https://github.com/CompeyDev/elytra-lock-fabric.git
synced 2025-01-05 18:59:09 +00:00
feat: handle left-handed UI case
This commit is contained in:
parent
0a9d2105ef
commit
0a82274e84
1 changed files with 9 additions and 1 deletions
|
@ -7,6 +7,7 @@ import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.client.render.RenderTickCounter;
|
import net.minecraft.client.render.RenderTickCounter;
|
||||||
import net.minecraft.client.util.Window;
|
import net.minecraft.client.util.Window;
|
||||||
|
import net.minecraft.util.Arm;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
public class HudRenderHandler implements HudRenderCallback {
|
public class HudRenderHandler implements HudRenderCallback {
|
||||||
|
@ -18,12 +19,19 @@ public class HudRenderHandler implements HudRenderCallback {
|
||||||
if (!MinecraftClient.isHudEnabled())
|
if (!MinecraftClient.isHudEnabled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
int offset = switch (ElytraLock.client.player.getMainArm()) {
|
||||||
|
case Arm.RIGHT:
|
||||||
|
yield 95;
|
||||||
|
case Arm.LEFT:
|
||||||
|
yield -115;
|
||||||
|
};
|
||||||
|
|
||||||
Identifier icon = Identifier.of("elytra-lock",
|
Identifier icon = Identifier.of("elytra-lock",
|
||||||
"textures/gui/" + (ElytraLock.isLocked() ? "locked" : "unlocked") + ".png");
|
"textures/gui/" + (ElytraLock.isLocked() ? "locked" : "unlocked") + ".png");
|
||||||
|
|
||||||
Window window = ElytraLock.client.getWindow();
|
Window window = ElytraLock.client.getWindow();
|
||||||
int width = window.getScaledWidth(), height = window.getScaledHeight();
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue