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.

feat: added initial position code

legoraft 81181f33 b310f290

+43 -21
+43 -21
src/client/java/com/armorhud/mixin/client/armorHudMixin.java
··· 25 25 public abstract class armorHudMixin { 26 26 27 27 @Shadow @Final private MinecraftClient client; 28 - 29 28 @Shadow protected abstract LivingEntity getRiddenEntity(); 30 - 31 29 @Unique int armorHeight; 32 30 @Unique boolean initialized; 31 + 32 + @Unique private final int FOODBAR_X = 91; 33 + @Unique private final int HEALTHBAR_X = -10; 33 34 34 35 @Inject(at = @At("TAIL"), method = "renderHotbar") 35 36 private void renderHud(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) { ··· 42 43 initialized = true; 43 44 } 44 45 45 - renderArmor(context); 46 + switch (config.position.name()) { 47 + case "FOODBAR": 48 + renderArmor(context, FOODBAR_X); 49 + break; 50 + case "HEALTHBAR": 51 + renderArmor(context, HEALTHBAR_X); 52 + break; 53 + default: 54 + renderArmor(context, FOODBAR_X); 55 + break; 56 + } 57 + 46 58 moveArmor(context); 47 59 } 48 60 49 61 @Unique 50 - private void renderArmor(DrawContext context) { 62 + private void renderArmor(DrawContext context, int startXPosition) { 51 63 int scaledWidth = context.getScaledWindowWidth(); 52 64 53 65 assert client.player != null; 54 - boolean rtl = config.RTL; 55 - ArmorAccessor armorAccessor = armorHud.getArmorAccessor(); 66 + ArmorAccessor armorAccessor = armorHud.getArmorAccessor(); 56 67 57 68 final int hungerWidth = 14; // Magic number to center 4 armor pieces 58 69 final int armorWidth = 15; 59 70 60 - // Added check for Above_Health_Bar -Dino 61 - float hungerX = scaledWidth / 2f + (client.player.getMaxHealth() + client.player.getMaxAbsorption() < 180 ? -10 : 91); 71 + float hungerX = scaledWidth / 2f + startXPosition; 72 + float x = hungerX + hungerWidth + 2; 73 + 62 74 EquipmentSlot[] slots = EquipmentSlot.values(); 75 + 76 + if (config.RTL) { 77 + for ( int i = slots.length - 1; i > 0; i-- ) { 78 + EquipmentSlot slot = slots[i]; 79 + x -= armorWidth; 80 + 81 + if (slot.isArmorSlot()) { 82 + renderArmorPiece(context, x, armorHeight, client.player, armorAccessor.getArmorPiece(client.player, slot)); 83 + } 84 + } 85 + } else { 86 + for (EquipmentSlot slot : slots) { 87 + x -= armorWidth; 88 + 89 + if (slot.isArmorSlot()) { 90 + renderArmorPiece(context, x, armorHeight, client.player, armorAccessor.getArmorPiece(client.player, slot)); 91 + } 92 + } 93 + } 94 + 95 + /* Putting this on the backburner for a little while to implement other things 63 96 // counts empty slots to center condensed armor bar, don't like having to loop through the equip slots twice but idk how else to center this dynamically -dino 64 97 int emptyArmorSlots = 0; 65 98 if (config.TRIM_EMPTY_SLOTS) { ··· 69 102 } 70 103 } 71 104 } 72 - float x = hungerX + hungerWidth - (7*emptyArmorSlots) + 2; 73 105 74 - 75 - for (int i = rtl ? slots.length-1 : 0; rtl ? i >= 0 : i < slots.length; i += rtl ? -1 : 1) { 76 - EquipmentSlot slot = slots[i]; 77 - if(config.TRIM_EMPTY_SLOTS && slot.getType() == EquipmentSlot.Type.HUMANOID_ARMOR && client.player.getEquippedStack(slot).isEmpty()) { 78 - continue; 79 - }; 80 - x -= armorWidth; 81 - 82 - if (slot.isArmorSlot()) { 83 - renderArmorPiece(context, x, armorHeight, client.player, armorAccessor.getArmorPiece(client.player, slot)); 84 - } 85 - } 106 + float x = hungerX + hungerWidth - (7 * emptyArmorSlots) + 2; 107 + */ 86 108 } 87 109 88 110 // Pretty much the same as renderHotbarItem but with x and y as float parameters.