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: fixed empty slot trimming

legoraft 3e683cd5 3953bcf7

+27 -10
+27 -10
src/client/java/com/armorhud/mixin/client/armorHudMixin.java
··· 72 72 73 73 assert minecraft.player != null; 74 74 ArmorAccessor armorAccessor = armorHud.getArmorAccessor(); 75 + EquipmentSlot[] slots = EquipmentSlot.values(); 75 76 76 77 final int hungerWidth = 14; // Magic number to center 4 armor pieces 77 78 final int armorWidth = 15; 78 79 80 + int emptyArmorSlots = 0; 81 + if (config.TRIM_EMPTY_SLOTS) { 82 + for (EquipmentSlot slot : slots) { 83 + if (slot.isArmor()) { 84 + ItemStack stack = armorAccessor.getArmorPiece(minecraft.player, slot); 85 + if (stack.isEmpty()) { 86 + emptyArmorSlots++; 87 + } 88 + } 89 + } 90 + } 91 + 79 92 float hungerX = scaledWidth / 2f + startXPosition; 80 - float x = hungerX + hungerWidth + 2; 81 - 82 - EquipmentSlot[] slots = EquipmentSlot.values(); 93 + float x = hungerX + hungerWidth - (7 * emptyArmorSlots) + 2 - (armorWidth * 2); 94 + if ( config.TRIM_EMPTY_SLOTS ) { x += ( (float) hungerWidth / 2 ); } 83 95 84 96 if (config.RTL) { 85 97 for ( int i = slots.length - 1; i > 0; i-- ) { 86 98 EquipmentSlot slot = slots[i]; 99 + if (!slot.isArmor()) continue; 100 + ItemStack armor = armorAccessor.getArmorPiece(minecraft.player, slot); 101 + 102 + if (config.TRIM_EMPTY_SLOTS && armor.isEmpty()) continue; 87 103 x -= armorWidth; 88 104 89 - if ( slot.isArmor() ) { 90 - renderArmorPiece(context, x, armorHeight, minecraft.player, armorAccessor.getArmorPiece(minecraft.player, slot)); 91 - } 105 + renderArmorPiece(context, x, armorHeight, minecraft.player, armor); 92 106 } 93 107 } else { 94 108 for ( EquipmentSlot slot : slots ) { 95 - x -= armorWidth; 109 + if ( !slot.isArmor() ) continue; 110 + ItemStack armor = armorAccessor.getArmorPiece(minecraft.player, slot); 96 111 97 - if ( slot.isArmor() ) { 98 - renderArmorPiece(context, x, armorHeight, minecraft.player, armorAccessor.getArmorPiece(minecraft.player, slot)); 99 - } 112 + if ( config.TRIM_EMPTY_SLOTS && armor.isEmpty() ) continue; 113 + x -= armorWidth; 114 + 115 + renderArmorPiece(context, x, armorHeight, minecraft.player, armor); 100 116 } 101 117 } 118 + System.out.println(x); 102 119 103 120 /* Putting this on the backburner for a little while to implement other things - Legoraft 104 121