A mod that adds your armor to the hud modrinth.com/mod/simple-armor-hud
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

merge: updated dev branch to latest release

+163 -162
+9 -10
build.gradle
··· 1 1 plugins { 2 - id 'net.fabricmc.fabric-loom-remap' version "${loom_version}" 2 + id 'net.fabricmc.fabric-loom' version "${loom_version}" 3 3 id 'maven-publish' 4 4 } 5 5 ··· 47 47 dependencies { 48 48 // To change the versions see the gradle.properties file 49 49 minecraft "com.mojang:minecraft:${project.minecraft_version}" 50 - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" 51 - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" 50 + implementation "net.fabricmc:fabric-loader:${project.loader_version}" 52 51 53 - modApi "com.terraformersmc:modmenu:${project.modmenu_version}" 52 + api "com.terraformersmc:modmenu:${project.modmenu_version}" 54 53 55 54 // Fabric API. This is technically optional, but you probably want it anyway. 56 - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" 55 + implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" 57 56 58 57 // Accessories mod 59 - // modImplementation("io.wispforest:accessories-fabric:${project.accessories_version}") 58 + // implementation("io.wispforest:accessories-fabric:${project.accessories_version}") 60 59 } 61 60 62 61 processResources { ··· 68 67 } 69 68 70 69 tasks.withType(JavaCompile).configureEach { 71 - it.options.release = 21 70 + it.options.release = 25 72 71 } 73 72 74 73 java { 75 - sourceCompatibility = JavaVersion.VERSION_21 76 - targetCompatibility = JavaVersion.VERSION_21 74 + sourceCompatibility = JavaVersion.VERSION_25 75 + targetCompatibility = JavaVersion.VERSION_25 77 76 } 78 77 79 78 jar { ··· 100 99 // The repositories here will be used for publishing your artifact, not for 101 100 // retrieving dependencies. 102 101 } 103 - } 102 + }
+6 -7
gradle.properties
··· 4 4 5 5 # Fabric Properties 6 6 # check these on https://fabricmc.net/develop 7 - minecraft_version=1.21.11 8 - yarn_mappings=1.21.11+build.3 9 - loader_version=0.18.2 10 - loom_version=1.14-SNAPSHOT 7 + minecraft_version=26.1 8 + loader_version=0.19.2 9 + loom_version=1.16-SNAPSHOT 11 10 12 11 # Mod Properties 13 - mod_version=1.8.0 12 + mod_version=1.9.0 14 13 maven_group=com.armorhud 15 14 archives_base_name=simple-armor-hud 16 15 17 16 # Dependency properties 18 - fabric_version=0.139.5+1.21.11 19 - modmenu_version=17.0.0-alpha.1 17 + fabric_version=0.146.1+26.1.2 18 + modmenu_version=18.0.0-alpha.8 20 19 trinkets_version=3.10.0 21 20 accessories_version=1.4.3-beta+1.21.10
+1 -1
gradle/wrapper/gradle-wrapper.properties
··· 1 1 distributionBase=GRADLE_USER_HOME 2 2 distributionPath=wrapper/dists 3 - distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip 3 + distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip 4 4 networkTimeout=10000 5 5 validateDistributionUrl=true 6 6 zipStoreBase=GRADLE_USER_HOME
+5 -5
src/client/java/com/armorhud/armor/ArmorAccessor.java
··· 1 1 package com.armorhud.armor; 2 2 3 - import net.minecraft.client.network.ClientPlayerEntity; 4 - import net.minecraft.entity.EquipmentSlot; 5 - import net.minecraft.item.ItemStack; 3 + import net.minecraft.client.player.LocalPlayer; 4 + import net.minecraft.world.entity.EquipmentSlot; 5 + import net.minecraft.world.item.ItemStack; 6 6 7 7 public interface ArmorAccessor { 8 8 9 - default void initialize(ClientPlayerEntity player) { 9 + default void initialize(LocalPlayer player) { 10 10 } 11 11 12 - ItemStack getArmorPiece(ClientPlayerEntity player, EquipmentSlot slot); 12 + ItemStack getArmorPiece(LocalPlayer player, EquipmentSlot slot); 13 13 }
+6 -6
src/client/java/com/armorhud/armor/VanillaArmorAccessor.java
··· 1 1 package com.armorhud.armor; 2 2 3 - import net.minecraft.client.network.ClientPlayerEntity; 4 - import net.minecraft.entity.EquipmentSlot; 5 - import net.minecraft.item.ItemStack; 3 + import net.minecraft.client.player.LocalPlayer; 4 + import net.minecraft.world.entity.EquipmentSlot; 5 + import net.minecraft.world.item.ItemStack; 6 6 7 7 public class VanillaArmorAccessor implements ArmorAccessor { 8 8 9 - public ItemStack getArmorPiece(ClientPlayerEntity player, EquipmentSlot slot) { 10 - if (!slot.isArmorSlot()) { 9 + public ItemStack getArmorPiece(LocalPlayer player, EquipmentSlot slot) { 10 + if (!slot.isArmor()) { 11 11 throw new IllegalArgumentException("Invalid slot type: " + slot); 12 12 } 13 13 14 - return player.getEquippedStack(slot); 14 + return player.getItemBySlot(slot); 15 15 } 16 16 }
+1 -1
src/client/java/com/armorhud/armorHud.java
··· 28 28 29 29 public void handleKeys() { 30 30 ClientTickEvents.END_CLIENT_TICK.register(client -> { 31 - if (keyBindings.armorHudToggle.wasPressed()) { 31 + if (keyBindings.armorHudToggle.consumeClick()) { 32 32 config.ARMOR_HUD = !config.ARMOR_HUD; 33 33 } 34 34 });
+3 -3
src/client/java/com/armorhud/config/config.java
··· 1 1 package com.armorhud.config; 2 2 3 3 import net.fabricmc.loader.api.FabricLoader; 4 - import net.minecraft.text.Text; 4 + import net.minecraft.network.chat.Component; 5 5 import org.apache.logging.log4j.LogManager; 6 6 7 7 import java.io.IOException; ··· 27 27 HOTBAR_LEFT, 28 28 HOTBAR_RIGHT; 29 29 30 - public Text displayName() { 31 - return Text.translatable("config.armorposition." + name().toLowerCase()); 30 + public Component displayName() { 31 + return Component.translatable("config.armorposition." + name().toLowerCase()); 32 32 } 33 33 } 34 34
+51 -48
src/client/java/com/armorhud/config/configScreen.java
··· 2 2 3 3 import net.fabricmc.api.EnvType; 4 4 import net.fabricmc.api.Environment; 5 - import net.minecraft.client.MinecraftClient; 6 - import net.minecraft.client.gui.DrawContext; 7 - import net.minecraft.client.gui.screen.Screen; 8 - import net.minecraft.client.gui.screen.option.GameOptionsScreen; 9 - import net.minecraft.client.gui.widget.*; 10 - import net.minecraft.text.Text; 5 + import net.minecraft.client.Minecraft; 6 + import net.minecraft.client.gui.GuiGraphicsExtractor; 7 + import net.minecraft.client.gui.components.Button; 8 + import net.minecraft.client.gui.components.CycleButton; 9 + import net.minecraft.client.gui.components.OptionsList; 10 + import net.minecraft.client.gui.screens.Screen; 11 + import net.minecraft.client.gui.screens.options.OptionsSubScreen; 12 + import net.minecraft.client.gui.layouts.*; 13 + import net.minecraft.network.chat.Component; 11 14 12 15 @Environment(EnvType.CLIENT) 13 - public class configScreen extends GameOptionsScreen { 16 + public class configScreen extends OptionsSubScreen { 14 17 private final Screen parent; 15 18 16 19 public configScreen(Screen parent) { 17 - super(parent, MinecraftClient.getInstance().options, Text.translatable("config.title")); 20 + super(parent, Minecraft.getInstance().options, Component.translatable("config.title")); 18 21 this.parent = parent; 19 22 } 20 23 21 - public CyclingButtonWidget<?> doubleHotbarToggle; 22 - public CyclingButtonWidget<?> betterMountHudToggle; 23 - public CyclingButtonWidget<?> armorHudToggle; 24 - public CyclingButtonWidget<?> disableArmorBar; 25 - public CyclingButtonWidget<?> armorPosition; 26 - public CyclingButtonWidget<?> rightToLeftToggle; 27 - public CyclingButtonWidget<?> trimEmptySlots; 24 + public CycleButton<?> doubleHotbarToggle; 25 + public CycleButton<?> betterMountHudToggle; 26 + public CycleButton<?> armorHudToggle; 27 + public CycleButton<?> disableArmorBar; 28 + public CycleButton<?> armorPosition; 29 + public CycleButton<?> rightToLeftToggle; 30 + public CycleButton<?> trimEmptySlots; 28 31 29 - public ButtonWidget doneButton; 32 + public Button doneButton; 30 33 31 34 @Override 32 35 protected void init() { 33 - doubleHotbarToggle = CyclingButtonWidget.onOffBuilder(config.DOUBLE_HOTBAR) 34 - .build(Text.translatable("config.doublehotbar"), ((button, value) -> config.DOUBLE_HOTBAR = !config.DOUBLE_HOTBAR)); 36 + doubleHotbarToggle = CycleButton.onOffBuilder(config.DOUBLE_HOTBAR) 37 + .create(Component.translatable("config.doublehotbar"), ((button, value) -> config.DOUBLE_HOTBAR = !config.DOUBLE_HOTBAR)); 35 38 36 - betterMountHudToggle = CyclingButtonWidget.onOffBuilder(config.BETTER_MOUNT_HUD) 37 - .build(Text.translatable("config.bettermounthud"), (button, value) -> config.BETTER_MOUNT_HUD = !config.BETTER_MOUNT_HUD); 39 + betterMountHudToggle = CycleButton.onOffBuilder(config.BETTER_MOUNT_HUD) 40 + .create(Component.translatable("config.bettermounthud"), (button, value) -> config.BETTER_MOUNT_HUD = !config.BETTER_MOUNT_HUD); 38 41 39 - armorHudToggle = CyclingButtonWidget.onOffBuilder(config.ARMOR_HUD) 40 - .build(Text.translatable("config.armorvisible"), (button, value) -> config.ARMOR_HUD = !config.ARMOR_HUD); 42 + armorHudToggle = CycleButton.onOffBuilder(config.ARMOR_HUD) 43 + .create(Component.translatable("config.armorvisible"), (button, value) -> config.ARMOR_HUD = !config.ARMOR_HUD); 41 44 42 - disableArmorBar = CyclingButtonWidget.onOffBuilder(config.DISABLE_ARMOR_BAR) 43 - .build(Text.translatable("config.disablearmorbar"), ((button, value) -> config.DISABLE_ARMOR_BAR = !config.DISABLE_ARMOR_BAR)); 45 + disableArmorBar = CycleButton.onOffBuilder(config.DISABLE_ARMOR_BAR) 46 + .create(Component.translatable("config.disablearmorbar"), ((button, value) -> config.DISABLE_ARMOR_BAR = !config.DISABLE_ARMOR_BAR)); 44 47 45 - armorPosition = CyclingButtonWidget.builder(config.Position::displayName, config.Position.valueOf(String.valueOf(config.position))).values(config.Position.values()) 46 - .build(Text.translatable("config.armorposition"), ((button, value) -> config.position = value)); 48 + armorPosition = CycleButton.builder(config.Position::displayName, config.Position.valueOf(String.valueOf(config.position))).withValues(config.Position.values()) 49 + .create(Component.translatable("config.armorposition"), ((button, value) -> config.position = value)); 47 50 48 - rightToLeftToggle = CyclingButtonWidget.onOffBuilder(config.RTL) 49 - .build(Text.translatable("config.righttoleft"), (button, value) -> config.RTL = !config.RTL); 51 + rightToLeftToggle = CycleButton.onOffBuilder(config.RTL) 52 + .create(Component.translatable("config.righttoleft"), (button, value) -> config.RTL = !config.RTL); 50 53 51 - trimEmptySlots = CyclingButtonWidget.onOffBuilder(config.TRIM_EMPTY_SLOTS) 52 - .build(Text.translatable("config.trimemptyslots"), ((button, value) -> config.TRIM_EMPTY_SLOTS = !config.TRIM_EMPTY_SLOTS)); 54 + trimEmptySlots = CycleButton.onOffBuilder(config.TRIM_EMPTY_SLOTS) 55 + .create(Component.translatable("config.trimemptyslots"), ((button, value) -> config.TRIM_EMPTY_SLOTS = !config.TRIM_EMPTY_SLOTS)); 53 56 54 - doneButton = ButtonWidget 55 - .builder(Text.translatable("config.done"), button -> close()) 56 - .dimensions(width / 2 - 100, height - 25, 200, 20) 57 + doneButton = Button 58 + .builder(Component.translatable("config.done"), button -> onClose()) 59 + .bounds(width / 2 - 100, height - 25, 200, 20) 57 60 .build(); 58 61 59 - OptionListWidget optionListWidget = this.addDrawableChild(new OptionListWidget(this.client, this.width, this)); 60 - optionListWidget.addHeader(Text.translatable("config.header.general")); 61 - optionListWidget.addWidgetEntry(armorHudToggle, disableArmorBar); 62 + OptionsList optionListWidget = this.addRenderableWidget(new OptionsList(this.minecraft, this.width, this)); 63 + optionListWidget.addHeader(Component.translatable("config.header.general")); 64 + optionListWidget.addSmall(armorHudToggle, disableArmorBar); 62 65 63 - optionListWidget.addHeader(Text.translatable("config.header.compatibility")); 64 - optionListWidget.addWidgetEntry(betterMountHudToggle, doubleHotbarToggle); 66 + optionListWidget.addHeader(Component.translatable("config.header.compatibility")); 67 + optionListWidget.addSmall(betterMountHudToggle, doubleHotbarToggle); 65 68 66 - optionListWidget.addHeader(Text.translatable("config.header.display")); 67 - optionListWidget.addWidgetEntry(armorPosition, rightToLeftToggle); 68 - optionListWidget.addWidgetEntry(trimEmptySlots, null); 69 + optionListWidget.addHeader(Component.translatable("config.header.display")); 70 + optionListWidget.addSmall(armorPosition, rightToLeftToggle); 71 + optionListWidget.addSmall(trimEmptySlots, null); 69 72 70 - addDrawableChild(doneButton); 73 + addRenderableWidget(doneButton); 71 74 } 72 75 73 76 @Override 74 77 protected void addOptions() { } 75 78 76 79 @Override 77 - public void render(DrawContext context, int mouseX, int mouseY, float delta) { 78 - context.drawCenteredTextWithShadow(this.textRenderer, Text.translatable("config.title"), this.width / 2, 12, 0xffffff); 79 - super.render(context, mouseX, mouseY, delta); 80 + public void extractRenderState(GuiGraphicsExtractor context, int mouseX, int mouseY, float delta) { 81 + context.centeredText(this.font, Component.translatable("config.title"), this.width / 2, 12, 0xffffff); 82 + super.extractRenderState(context, mouseX, mouseY, delta); 80 83 } 81 84 82 85 @Override 83 - public void close() { 84 - assert this.client != null; 86 + public void onClose() { 87 + assert this.minecraft != null; 85 88 86 89 config.save(); 87 - this.client.setScreen(this.parent); 90 + this.minecraft.setScreen(this.parent); 88 91 } 89 92 }
+8 -8
src/client/java/com/armorhud/keyBindings.java
··· 1 1 package com.armorhud; 2 2 3 - import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; 4 - import net.minecraft.client.option.KeyBinding; 5 - import net.minecraft.client.util.InputUtil; 6 - import net.minecraft.util.Identifier; 3 + import net.fabricmc.fabric.api.client.keymapping.v1.KeyMappingHelper; 4 + import net.minecraft.client.KeyMapping; 5 + import com.mojang.blaze3d.platform.InputConstants; 6 + import net.minecraft.resources.Identifier; 7 7 8 8 public class keyBindings { 9 9 10 - public static KeyBinding armorHudToggle; 10 + public static KeyMapping armorHudToggle; 11 11 12 12 public static void registerKeys() { 13 - final KeyBinding.Category category = KeyBinding.Category.create(Identifier.of("simple-armor-hud", "armorhud.toggles")); 14 - armorHudToggle = KeyBindingHelper.registerKeyBinding(new KeyBinding( 13 + final KeyMapping.Category category = KeyMapping.Category.register(Identifier.fromNamespaceAndPath("simple-armor-hud", "armorhud.toggles")); 14 + armorHudToggle = KeyMappingHelper.registerKeyMapping(new KeyMapping( 15 15 "key.armorhud.armorvisible", 16 - InputUtil.UNKNOWN_KEY.getCode(), 16 + InputConstants.UNKNOWN.getValue(), 17 17 category 18 18 )); 19 19 }
+53 -53
src/client/java/com/armorhud/mixin/client/armorHudMixin.java
··· 3 3 import com.armorhud.armor.ArmorAccessor; 4 4 import com.armorhud.armorHud; 5 5 import com.armorhud.config.config; 6 - import net.minecraft.client.MinecraftClient; 7 - import net.minecraft.client.gui.DrawContext; 8 - import net.minecraft.client.gui.hud.InGameHud; 9 - import net.minecraft.client.option.AttackIndicator; 10 - import net.minecraft.client.render.RenderTickCounter; 11 - import net.minecraft.entity.EquipmentSlot; 12 - import net.minecraft.entity.LivingEntity; 13 - import net.minecraft.entity.player.PlayerEntity; 14 - import net.minecraft.item.ItemStack; 6 + import net.minecraft.client.Minecraft; 7 + import net.minecraft.client.gui.GuiGraphicsExtractor; 8 + import net.minecraft.client.gui.Gui; 9 + import net.minecraft.client.AttackIndicatorStatus; 10 + import net.minecraft.client.DeltaTracker; 11 + import net.minecraft.world.entity.EquipmentSlot; 12 + import net.minecraft.world.entity.LivingEntity; 13 + import net.minecraft.world.entity.player.Player; 14 + import net.minecraft.world.item.ItemStack; 15 15 import org.spongepowered.asm.mixin.Final; 16 16 import org.spongepowered.asm.mixin.Mixin; 17 17 import org.spongepowered.asm.mixin.Shadow; ··· 20 20 import org.spongepowered.asm.mixin.injection.Inject; 21 21 import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 22 22 23 - @Mixin(InGameHud.class) 23 + @Mixin(Gui.class) 24 24 public abstract class armorHudMixin { 25 25 26 - @Shadow @Final private MinecraftClient client; 27 - @Shadow protected abstract LivingEntity getRiddenEntity(); 26 + @Shadow @Final private Minecraft minecraft; 27 + @Shadow protected abstract LivingEntity getPlayerVehicleWithHealth(); 28 28 @Unique int armorHeight; 29 29 @Unique boolean initialized; 30 30 ··· 33 33 @Unique private final int HOTBAR_LEFT_X = -83; 34 34 @Unique private final int HOTBAR_RIGHT_X = 165; 35 35 36 - @Inject(at = @At("TAIL"), method = "renderHotbar") 37 - private void renderHud(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) { 36 + @Inject(at = @At("TAIL"), method = "extractItemHotbar") 37 + private void renderHud(GuiGraphicsExtractor graphics, DeltaTracker deltaTracker, CallbackInfo ci) { 38 38 if( !config.ARMOR_HUD ) { return; } 39 39 40 - assert client.player != null; 40 + assert minecraft.player != null; 41 41 42 42 if ( !initialized ) { 43 - armorHud.getArmorAccessor().initialize(client.player); 43 + armorHud.getArmorAccessor().initialize(minecraft.player); 44 44 initialized = true; 45 45 } 46 46 47 47 switch ( config.position.name() ) { 48 48 case "FOODBAR": 49 - renderArmor(context, FOODBAR_X); 49 + renderArmor(graphics, FOODBAR_X); 50 50 break; 51 51 case "HEALTHBAR": 52 - renderArmor(context, HEALTHBAR_X); 52 + renderArmor(graphics, HEALTHBAR_X); 53 53 break; 54 54 case "HOTBAR_LEFT": 55 - renderArmor(context, HOTBAR_LEFT_X); 55 + renderArmor(graphics, HOTBAR_LEFT_X); 56 56 break; 57 57 case "HOTBAR_RIGHT": 58 - if ( client.options.getAttackIndicator().getValue() == AttackIndicator.HOTBAR ) { 59 - renderArmor(context, HOTBAR_RIGHT_X + 25); 58 + if ( minecraft.options.attackIndicator().get() == AttackIndicatorStatus.HOTBAR ) { 59 + renderArmor(graphics, HOTBAR_RIGHT_X + 25); 60 60 } else { 61 - renderArmor(context, HOTBAR_RIGHT_X); 61 + renderArmor(graphics, HOTBAR_RIGHT_X); 62 62 } 63 63 break; 64 64 } 65 65 66 - moveArmor(context); 66 + moveArmor(graphics); 67 67 } 68 68 69 69 @Unique 70 - private void renderArmor(DrawContext context, int startXPosition) { 71 - int scaledWidth = context.getScaledWindowWidth(); 70 + private void renderArmor(GuiGraphicsExtractor context, int startXPosition) { 71 + int scaledWidth = context.guiWidth(); 72 72 73 - assert client.player != null; 73 + assert minecraft.player != null; 74 74 ArmorAccessor armorAccessor = armorHud.getArmorAccessor(); 75 75 76 76 final int hungerWidth = 14; // Magic number to center 4 armor pieces ··· 86 86 EquipmentSlot slot = slots[i]; 87 87 x -= armorWidth; 88 88 89 - if ( slot.isArmorSlot() ) { 90 - renderArmorPiece(context, x, armorHeight, client.player, armorAccessor.getArmorPiece(client.player, slot)); 89 + if ( slot.isArmor() ) { 90 + renderArmorPiece(context, x, armorHeight, minecraft.player, armorAccessor.getArmorPiece(minecraft.player, slot)); 91 91 } 92 92 } 93 93 } else { 94 94 for ( EquipmentSlot slot : slots ) { 95 95 x -= armorWidth; 96 96 97 - if ( slot.isArmorSlot() ) { 98 - renderArmorPiece(context, x, armorHeight, client.player, armorAccessor.getArmorPiece(client.player, slot)); 97 + if ( slot.isArmor() ) { 98 + renderArmorPiece(context, x, armorHeight, minecraft.player, armorAccessor.getArmorPiece(minecraft.player, slot)); 99 99 } 100 100 } 101 101 } ··· 117 117 } 118 118 119 119 @Unique 120 - private void moveArmor(DrawContext context) { 120 + private void moveArmor(GuiGraphicsExtractor context) { 121 121 if ( config.position != config.Position.FOODBAR && config.position != config.Position.HEALTHBAR ) { 122 - int scaledHeight = context.getScaledWindowHeight(); 122 + int scaledHeight = context.guiHeight(); 123 123 124 124 switch ( config.position.name() ) { 125 125 case "HOTBAR_LEFT", "HOTBAR_RIGHT": ··· 130 130 return; 131 131 } 132 132 133 - int scaledHeight = context.getScaledWindowHeight(); 133 + int scaledHeight = context.guiHeight(); 134 134 int healthDisplacement = 0; 135 - assert client.player != null; 135 + assert minecraft.player != null; 136 136 137 137 // Moves armorhud up if player uses double hotbar 138 138 armorHeight = scaledHeight - (config.DOUBLE_HOTBAR ? 76 : 55); ··· 142 142 Note: setting gets turned off above 9 rows of hearts, since the hud will fly off the screen at some point -Dino */ 143 143 144 144 if ( config.position == config.Position.HEALTHBAR ) { 145 - if ( client.player.getMaxHealth() + client.player.getMaxAbsorption() < 180 ) { 145 + if ( minecraft.player.getMaxHealth() + minecraft.player.getMaxAbsorption() < 180 ) { 146 146 /* Displacement calculation extracted for clarity. -Dino 147 147 Calc breaks above 90 hearts since hearts don't get condensed further, so it overshoots down -Dino */ 148 - int playerHealthRows = (int) Math.ceil((client.player.getMaxHealth() + client.player.getMaxAbsorption()) / 20); 148 + int playerHealthRows = (int) Math.ceil((minecraft.player.getMaxHealth() + minecraft.player.getMaxAbsorption()) / 20); 149 149 healthDisplacement = (10 * playerHealthRows) - ((playerHealthRows>2) ? (playerHealthRows -2) * (playerHealthRows -1) : 0); 150 150 151 151 // Moves armorhud up depending on how much health you have, along with negative displacement from higher heart counts -Dino 152 152 armorHeight -= healthDisplacement; 153 153 } 154 154 155 - if ( client.player.isCreative() ) { 155 + if ( minecraft.player.isCreative() ) { 156 156 armorHeight += 16 + healthDisplacement; 157 157 } else if ( config.DISABLE_ARMOR_BAR ) { 158 158 armorHeight += 10; 159 159 } 160 160 } else { 161 - if ( client.player.getAir() < client.player.getMaxAir() || client.player.isSubmergedInWater() && !client.player.isCreative() ) { 161 + if ( minecraft.player.getAirSupply() < minecraft.player.getMaxAirSupply() || minecraft.player.isUnderWater() && !minecraft.player.isCreative() ) { 162 162 armorHeight -= 10; 163 163 } 164 164 165 165 // Moves armorhud down if player is in creative 166 - if ( client.player.isCreative() ) { 166 + if ( minecraft.player.isCreative() ) { 167 167 armorHeight += 16; 168 168 } 169 169 170 170 // Moves armorhud up if player is on mount, like horse 171 - if ( client.player.hasVehicle() && getRiddenEntity() != null ) { 171 + if ( minecraft.player.isPassenger() && getPlayerVehicleWithHealth() != null ) { 172 172 moveRiddenEntity(); 173 173 } 174 174 } ··· 176 176 177 177 @Unique 178 178 private void moveRiddenEntity() { 179 - assert client.player != null; 179 + assert minecraft.player != null; 180 180 181 181 // Check if entity player is riding is alive, like a horse 182 - if ( getRiddenEntity().isAlive() ) { 182 + if ( getPlayerVehicleWithHealth().isAlive() ) { 183 183 184 184 // If horse health is 21, it still displays 10 hearts 185 - if ( getRiddenEntity().getMaxHealth() > 21 ) { 186 - if ( config.BETTER_MOUNT_HUD && !client.player.isCreative() ) { 185 + if ( getPlayerVehicleWithHealth().getMaxHealth() > 21 ) { 186 + if ( config.BETTER_MOUNT_HUD && !minecraft.player.isCreative() ) { 187 187 armorHeight -= 20; 188 188 } else { 189 - armorHeight -= (client.player.isCreative() ? 26 : 10); 189 + armorHeight -= (minecraft.player.isCreative() ? 26 : 10); 190 190 } 191 191 } 192 192 193 193 // Armor hud only has to be moved up if better mount hud is enabled or player is in creative 194 194 else { 195 - if ( config.BETTER_MOUNT_HUD && !client.player.isCreative() ) { 195 + if ( config.BETTER_MOUNT_HUD && !minecraft.player.isCreative() ) { 196 196 armorHeight -= 10; 197 - } else if ( client.player.isCreative() ) { 197 + } else if ( minecraft.player.isCreative() ) { 198 198 armorHeight -= 16; 199 199 } 200 200 } ··· 203 203 204 204 // Pretty much the same as renderHotbarItem but with x and y as float parameters. 205 205 @Unique 206 - private void renderArmorPiece(DrawContext context, float x, float y, PlayerEntity player, ItemStack stack) { 206 + private void renderArmorPiece(GuiGraphicsExtractor context, float x, float y, Player player, ItemStack stack) { 207 207 if ( stack.isEmpty() ) return; 208 208 209 - context.getMatrices().pushMatrix(); 210 - context.getMatrices().translate(x, y); 209 + context.pose().pushMatrix(); 210 + context.pose().translate(x, y); 211 211 212 - context.drawItem(player, stack, 0, 0, 1); 212 + context.item(player, stack, 0, 0, 1); 213 213 214 - context.drawStackOverlay(this.client.textRenderer, stack, 0,0); 215 - context.getMatrices().popMatrix(); 214 + context.itemDecorations(this.minecraft.font, stack, 0,0); 215 + context.pose().popMatrix(); 216 216 } 217 217 218 218 }
+6 -6
src/client/java/com/armorhud/mixin/client/inGameHudMixin.java
··· 1 1 package com.armorhud.mixin.client; 2 2 3 3 import com.armorhud.config.config; 4 - import net.minecraft.client.gui.DrawContext; 5 - import net.minecraft.client.gui.hud.InGameHud; 6 - import net.minecraft.entity.player.PlayerEntity; 4 + import net.minecraft.client.gui.GuiGraphicsExtractor; 5 + import net.minecraft.client.gui.Gui; 6 + import net.minecraft.world.entity.player.Player; 7 7 import org.jetbrains.annotations.Nullable; 8 8 import org.spongepowered.asm.mixin.Mixin; 9 9 import org.spongepowered.asm.mixin.Shadow; ··· 12 12 import org.spongepowered.asm.mixin.injection.ModifyVariable; 13 13 import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 14 14 15 - @Mixin(InGameHud.class) 15 + @Mixin(Gui.class) 16 16 17 17 public abstract class inGameHudMixin { 18 18 19 - @Inject(method = "renderArmor", at=@At("HEAD"), cancellable = true) 20 - private static void checkArmor(DrawContext context, PlayerEntity player, int i, int j, int k, int x, CallbackInfo ci) { 19 + @Inject(method = "extractArmor", at=@At("HEAD"), cancellable = true) 20 + private static void checkArmor(GuiGraphicsExtractor context, Player player, int i, int j, int k, int x, CallbackInfo ci) { 21 21 if (config.DISABLE_ARMOR_BAR) { 22 22 ci.cancel(); 23 23 }
+6 -6
src/client/java/com/armorhud/mixin/client/tooltipMixin.java
··· 1 1 package com.armorhud.mixin.client; 2 2 3 - import net.minecraft.client.gui.DrawContext; 4 - import net.minecraft.client.gui.hud.InGameHud; 3 + import net.minecraft.client.gui.GuiGraphicsExtractor; 4 + import net.minecraft.client.gui.Gui; 5 5 import org.spongepowered.asm.mixin.Mixin; 6 6 import org.spongepowered.asm.mixin.injection.At; 7 7 import org.spongepowered.asm.mixin.injection.ModifyVariable; 8 8 9 - @Mixin(InGameHud.class) 9 + @Mixin(Gui.class) 10 10 11 11 public abstract class tooltipMixin { 12 12 13 - @ModifyVariable(method = "renderHeldItemTooltip", at = @At("STORE"), ordinal = 2) 14 - public int renderHeldItemTooltip(int k, DrawContext context) { 15 - return context.getScaledWindowHeight() - 62; 13 + @ModifyVariable(method = "extractSelectedItemName", at = @At("STORE"), ordinal = 2) 14 + public int renderHeldItemTooltip(int k, GuiGraphicsExtractor context) { 15 + return context.guiHeight() - 62; 16 16 } 17 17 18 18 }
+1 -1
src/client/java/com/armorhud/util/armorHudModMenu.java
··· 3 3 import com.armorhud.config.configScreen; 4 4 import com.terraformersmc.modmenu.api.ConfigScreenFactory; 5 5 import com.terraformersmc.modmenu.api.ModMenuApi; 6 - import net.minecraft.client.gui.screen.Screen; 6 + import net.minecraft.client.gui.screens.Screen; 7 7 8 8 public class armorHudModMenu implements ModMenuApi { 9 9
+2 -2
src/client/resources/simple-armor-hud.client.mixins.json
··· 1 1 { 2 2 "required": true, 3 3 "package": "com.armorhud.mixin.client", 4 - "compatibilityLevel": "JAVA_17", 4 + "compatibilityLevel": "JAVA_25", 5 5 "client": [ 6 6 "armorHudMixin", 7 7 "inGameHudMixin", ··· 10 10 "injectors": { 11 11 "defaultRequire": 1 12 12 } 13 - } 13 + }
+3 -3
src/main/resources/fabric.mod.json
··· 29 29 } 30 30 ], 31 31 "depends": { 32 - "fabricloader": ">=0.14.19", 33 - "minecraft": ">=1.19", 34 - "java": ">=17" 32 + "fabricloader": ">=0.19.2", 33 + "minecraft": ">=26.1", 34 + "java": ">=25" 35 35 }, 36 36 "suggests": { 37 37 "trinkets": ">=3.7.1"
+2 -2
src/main/resources/simple-armor-hud.mixins.json
··· 1 1 { 2 2 "required": true, 3 3 "package": "com.armorhud.mixin", 4 - "compatibilityLevel": "JAVA_17", 4 + "compatibilityLevel": "JAVA_25", 5 5 "mixins": [ 6 6 ], 7 7 "injectors": { 8 8 "defaultRequire": 1 9 9 } 10 - } 10 + }