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: update to 1.21.5

Updated to 1.21.5

authored by

Legoraft and committed by
GitHub
903144df b0188e72

+35 -47
+2 -2
build.gradle
··· 1 1 plugins { 2 - id 'fabric-loom' version '1.9-SNAPSHOT' 2 + id 'fabric-loom' version '1.10-SNAPSHOT' 3 3 id 'maven-publish' 4 4 5 5 } ··· 56 56 57 57 // modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}" 58 58 59 - modImplementation "dev.emi:trinkets:${project.trinkets_version}" 59 + // modImplementation "dev.emi:trinkets:${project.trinkets_version}" 60 60 } 61 61 62 62 processResources {
+5 -5
gradle.properties
··· 4 4 5 5 # Fabric Properties 6 6 # check these on https://fabricmc.net/develop 7 - minecraft_version=1.21.4 8 - yarn_mappings=1.21.4+build.1 9 - loader_version=0.16.9 7 + minecraft_version=1.21.5 8 + yarn_mappings=1.21.5+build.1 9 + loader_version=0.16.14 10 10 11 11 # Mod Properties 12 12 mod_version=1.5.1 ··· 14 14 archives_base_name=simple-armor-hud 15 15 16 16 # Dependency properties 17 - fabric_version=0.110.5+1.21.4 18 - modmenu_version=13.0.0-beta.1 17 + fabric_version=0.122.0+1.21.5 18 + modmenu_version=14.0.0-rc.2 19 19 trinkets_version=3.10.0
+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-8.11.1-bin.zip 3 + distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip 4 4 networkTimeout=10000 5 5 zipStoreBase=GRADLE_USER_HOME 6 6 zipStorePath=wrapper/dists
+2 -3
src/client/java/com/armorhud/armor/ArmorAccessor.java
··· 1 1 package com.armorhud.armor; 2 2 3 3 import net.minecraft.client.network.ClientPlayerEntity; 4 + import net.minecraft.entity.EquipmentSlot; 4 5 import net.minecraft.item.ItemStack; 5 6 6 7 public interface ArmorAccessor { ··· 8 9 default void initialize(ClientPlayerEntity player) { 9 10 } 10 11 11 - ItemStack getArmorPiece(ClientPlayerEntity player, int slotIndex); 12 - 13 - int getPieces(ClientPlayerEntity player); 12 + ItemStack getArmorPiece(ClientPlayerEntity player, EquipmentSlot slot); 14 13 }
+3
src/client/java/com/armorhud/armor/TrinketsArmorAccessor.java
··· 1 + /* 1 2 package com.armorhud.armor; 2 3 3 4 import dev.emi.trinkets.api.SlotReference; ··· 88 89 private interface SlotFunction extends Function<ClientPlayerEntity, ItemStack> { 89 90 } 90 91 } 92 + 93 + */
+5 -9
src/client/java/com/armorhud/armor/VanillaArmorAccessor.java
··· 1 1 package com.armorhud.armor; 2 2 3 3 import net.minecraft.client.network.ClientPlayerEntity; 4 + import net.minecraft.entity.EquipmentSlot; 4 5 import net.minecraft.item.ItemStack; 5 6 6 7 public class VanillaArmorAccessor implements ArmorAccessor { 7 8 8 - @Override 9 - public ItemStack getArmorPiece(ClientPlayerEntity player, int slotIndex) { 10 - if (slotIndex < 0 || slotIndex >= getPieces(player)) { 11 - throw new IllegalArgumentException("Invalid slot index: " + slotIndex); 9 + public ItemStack getArmorPiece(ClientPlayerEntity player, EquipmentSlot slot) { 10 + if (!slot.isArmorSlot()) { 11 + throw new IllegalArgumentException("Invalid slot type: " + slot); 12 12 } 13 - return player.getInventory().getArmorStack(slotIndex); 14 - } 15 13 16 - @Override 17 - public int getPieces(ClientPlayerEntity player) { 18 - return player.getInventory().armor.size(); 14 + return player.getEquippedStack(slot); 19 15 } 20 16 }
-4
src/client/java/com/armorhud/armorHud.java
··· 34 34 }); 35 35 } 36 36 37 - public static void setArmorAccessor(ArmorAccessor armorAccessor) { 38 - armorHud.armorAccessor = armorAccessor; 39 - } 40 - 41 37 public static ArmorAccessor getArmorAccessor() { 42 38 return armorAccessor; 43 39 }
+12 -18
src/client/java/com/armorhud/mixin/client/armorHudMixin.java
··· 7 7 import net.minecraft.client.gui.DrawContext; 8 8 import net.minecraft.client.gui.hud.InGameHud; 9 9 import net.minecraft.client.render.RenderTickCounter; 10 + import net.minecraft.entity.EquipmentSlot; 10 11 import net.minecraft.entity.LivingEntity; 11 12 import net.minecraft.entity.player.PlayerEntity; 12 13 import net.minecraft.item.ItemStack; ··· 25 26 26 27 @Shadow protected abstract LivingEntity getRiddenEntity(); 27 28 28 - @Shadow public abstract void tick(boolean paused); 29 - 30 29 @Unique int armorHeight; 31 30 @Unique boolean initialized; 32 31 ··· 41 40 initialized = true; 42 41 } 43 42 44 - renderArmor(context, tickCounter); 43 + renderArmor(context); 45 44 moveArmor(context); 46 45 } 47 46 48 47 @Unique 49 - private void renderArmor(DrawContext context, RenderTickCounter tickCounter) { 48 + private void renderArmor(DrawContext context) { 50 49 int scaledWidth = context.getScaledWindowWidth(); 51 50 52 51 assert client.player != null; 53 52 54 53 ArmorAccessor armorAccessor = armorHud.getArmorAccessor(); 55 - int pieces = armorAccessor.getPieces(client.player); 56 54 57 - final int hungerWidth = 80 + 8; // Bar advances 8 pixels to the left 10 times, 8 is added for the width of the last sprite. 55 + final int hungerWidth = 14; // Magic number to center 4 armor pieces 58 56 final int armorWidth = 15; 59 - final int barWidth = armorWidth * pieces; 57 + 60 58 // Added check for Above_Health_Bar -Dino 61 59 float hungerX = scaledWidth / 2f + (config.ABOVE_HEALTH_BAR 62 - && client.player.getMaxHealth() + client.player.getMaxAbsorption() < 180 ? -10 : 91); 63 - float x = hungerX - hungerWidth / 2f + barWidth / 2f; 60 + && client.player.getMaxHealth() + client.player.getMaxAbsorption() < 180 ? -10 : 91); 61 + float x = hungerX + hungerWidth; 64 62 x += 2; // This makes it look better because the helmet is thinner. 65 63 66 - for (int j = 0; j < pieces; j++) { 64 + for (EquipmentSlot slot : EquipmentSlot.values()) { 67 65 x -= armorWidth; 68 - int armorPiece; 69 66 70 - if (config.RTL) { 71 - armorPiece = (pieces - 1) - j; 72 - } else { 73 - armorPiece = j; 67 + if (slot.isArmorSlot()) { 68 + renderArmorPiece(context, x, armorHeight, client.player, armorAccessor.getArmorPiece(client.player, slot)); 74 69 } 75 - 76 - renderArmorPiece(context, x, armorHeight, tickCounter, client.player, armorAccessor.getArmorPiece(client.player, armorPiece)); 77 70 } 78 71 } 79 72 80 73 // Pretty much the same as renderHotbarItem but with x and y as float parameters. 81 74 @Unique 82 - private void renderArmorPiece(DrawContext context, float x, float y, RenderTickCounter tickCounter, PlayerEntity player, ItemStack stack) { 75 + private void renderArmorPiece(DrawContext context, float x, float y, PlayerEntity player, ItemStack stack) { 83 76 if (stack.isEmpty()) return; 84 77 85 78 context.getMatrices().push(); ··· 150 143 armorHeight -= (client.player.isCreative() ? 26 : 10); 151 144 } 152 145 } 146 + 153 147 // Armor hud only has to be moved up if better mount hud is enabled or player is in creative 154 148 else { 155 149 if (config.BETTER_MOUNT_HUD && !client.player.isCreative()) {
+5 -5
src/client/java/com/armorhud/util/modDetect.java
··· 1 1 package com.armorhud.util; 2 2 3 - import com.armorhud.armor.TrinketsArmorAccessor; 3 + // import com.armorhud.armor.TrinketsArmorAccessor; 4 4 import com.armorhud.armorHud; 5 5 import com.armorhud.config.config; 6 6 import net.fabricmc.loader.api.FabricLoader; ··· 16 16 config.DOUBLE_HOTBAR = true; 17 17 armorHud.LOGGER.info("Double hotbar found!"); 18 18 } 19 - if (FabricLoader.getInstance().isModLoaded("trinkets")) { 20 - armorHud.setArmorAccessor(new TrinketsArmorAccessor(armorHud.getArmorAccessor())); 21 - armorHud.LOGGER.info("Trinkets found!"); 22 - } 19 + // if (FabricLoader.getInstance().isModLoaded("trinkets")) { 20 + // armorHud.setArmorAccessor(new TrinketsArmorAccessor(armorHud.getArmorAccessor())); 21 + // armorHud.LOGGER.info("Trinkets found!"); 22 + // } 23 23 24 24 config.save(); 25 25 }