From a6a324a61ade15ef41722769837bdbe31e899656 Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Wed, 30 Sep 2026 17:42:48 +0200 Subject: [PATCH] Rename the Ref methods that share a name with vanilla methods WindowRef.getWidth/getHeight and ItemStackRef.isEmpty/getMaxDamage match methods of the classes they're mixed into, so the mixins can't implement them explicitly. With Mojang's names, Window.getWidth is also the framebuffer's width rather than the window's. They're now getWindowWidth/getWindowHeight and isEmptyStack/getMaxItemDamage (with getItemDamage to match). Co-Authored-By: Claude Opus 5.5 --- .../saturnclient/common/ref/game/ItemStackRef.java | 10 +++++++--- .../saturnclient/common/ref/render/WindowRef.java | 10 ++++++++-- .../org/saturnclient/mod/mods/ArmorDisplayMod.java | 14 +++++++------- .../org/saturnclient/ui/elements/ImageTexture.java | 4 ++-- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/saturnclient/common/ref/game/ItemStackRef.java b/src/main/java/org/saturnclient/common/ref/game/ItemStackRef.java index d20e38f..b5881d1 100644 --- a/src/main/java/org/saturnclient/common/ref/game/ItemStackRef.java +++ b/src/main/java/org/saturnclient/common/ref/game/ItemStackRef.java @@ -1,7 +1,11 @@ package org.saturnclient.common.ref.game; +/** + * An item stack. Its methods are implemented in ItemStackMixin, so their names must not match any of + * ItemStack's own methods. + */ public interface ItemStackRef { - public boolean isEmpty(); - public int getMaxDamage(); - public int getDamage(); + public boolean isEmptyStack(); + public int getMaxItemDamage(); + public int getItemDamage(); } diff --git a/src/main/java/org/saturnclient/common/ref/render/WindowRef.java b/src/main/java/org/saturnclient/common/ref/render/WindowRef.java index 73bac0e..37477f8 100644 --- a/src/main/java/org/saturnclient/common/ref/render/WindowRef.java +++ b/src/main/java/org/saturnclient/common/ref/render/WindowRef.java @@ -1,9 +1,15 @@ package org.saturnclient.common.ref.render; +/** + * The game window. Its methods are implemented in WindowMixin, so their names must not match any of + * Window's own methods. + */ public interface WindowRef { - public int getWidth(); + /** The window's width in screen coordinates */ + public int getWindowWidth(); - public int getHeight(); + /** The window's height in screen coordinates */ + public int getWindowHeight(); public int getFramebufferWidth(); diff --git a/src/main/java/org/saturnclient/mod/mods/ArmorDisplayMod.java b/src/main/java/org/saturnclient/mod/mods/ArmorDisplayMod.java index 84c72b8..6944d25 100644 --- a/src/main/java/org/saturnclient/mod/mods/ArmorDisplayMod.java +++ b/src/main/java/org/saturnclient/mod/mods/ArmorDisplayMod.java @@ -75,16 +75,16 @@ public class ArmorDisplayMod extends Mod implements HudMod { int row = 0; - if (useMainHand.value && !mainHand.isEmpty()) { + if (useMainHand.value && !mainHand.isEmptyStack()) { row = renderSlot(scope, mainHand, row); } - if (!helmet.isEmpty()) + if (!helmet.isEmptyStack()) row = renderSlot(scope, helmet, row); - if (!chestplate.isEmpty()) + if (!chestplate.isEmptyStack()) row = renderSlot(scope, chestplate, row); - if (!leggings.isEmpty()) + if (!leggings.isEmptyStack()) row = renderSlot(scope, leggings, row); - if (!boots.isEmpty()) + if (!boots.isEmptyStack()) row = renderSlot(scope, boots, row); } @@ -94,8 +94,8 @@ public class ArmorDisplayMod extends Mod implements HudMod { private int renderSlot(RenderScope scope, ItemStackRef item, int row) { scope.drawItem(item, 0, 15 * row); - if (item.getMaxDamage() > 0) { - int remaining = item.getMaxDamage() - item.getDamage(); + if (item.getMaxItemDamage() > 0) { + int remaining = item.getMaxItemDamage() - item.getItemDamage(); scope.drawText(0.5f, String.valueOf(remaining), 17, (15 * row) + 3, layout.font.value, layout.fgColor.value); diff --git a/src/main/java/org/saturnclient/ui/elements/ImageTexture.java b/src/main/java/org/saturnclient/ui/elements/ImageTexture.java index ca73287..7e85ea7 100644 --- a/src/main/java/org/saturnclient/ui/elements/ImageTexture.java +++ b/src/main/java/org/saturnclient/ui/elements/ImageTexture.java @@ -20,9 +20,9 @@ public class ImageTexture extends Element { if (sprite.toString().endsWith(".svg")) { MinecraftClientRef client = Providers.saturn.getClient(); - int renderWidth = (int) (width * client.getWindow().getFramebufferWidth() / client.getWindow().getWidth()); + int renderWidth = (int) (width * client.getWindow().getFramebufferWidth() / client.getWindow().getWindowWidth()); int renderHeight = (int) (height * client.getWindow().getFramebufferHeight() - / client.getWindow().getHeight()); + / client.getWindow().getWindowHeight()); IdentifierRef pngId = SvgTexture.getSvg(sprite, renderWidth * 2, renderHeight * 2); -- 2.54.0