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 remote-tracking branch 'origin/main' into dev merge: updated dev branch from main

+381 -156
+9 -12
.github/workflows/build.yml
··· 12 12 matrix: 13 13 # Use these Java versions 14 14 java: [ 15 - 21, # Current Java LTS & minimum supported by Minecraft 15 + 21, # Current Java LTS 16 16 ] 17 - # and run on both Linux and Windows 18 - os: [ubuntu-22.04, windows-2022] 19 - runs-on: ${{ matrix.os }} 17 + runs-on: ubuntu-22.04 20 18 steps: 21 19 - name: checkout repository 22 - uses: actions/checkout@v3 20 + uses: actions/checkout@v4 23 21 - name: validate gradle wrapper 24 - uses: gradle/wrapper-validation-action@v1 22 + uses: gradle/wrapper-validation-action@v2 25 23 - name: setup jdk ${{ matrix.java }} 26 - uses: actions/setup-java@v3 24 + uses: actions/setup-java@v4 27 25 with: 28 26 java-version: ${{ matrix.java }} 29 27 distribution: 'microsoft' 30 28 - name: make gradle wrapper executable 31 - if: ${{ runner.os != 'Windows' }} 32 29 run: chmod +x ./gradlew 33 30 - name: build 34 31 run: ./gradlew build 35 32 - name: capture build artifacts 36 - if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from latest java on one OS 37 - uses: actions/upload-artifact@v3 33 + if: ${{ matrix.java == '21' }} # Only upload artifacts built from latest java 34 + uses: actions/upload-artifact@v4 38 35 with: 39 - name: armorhud-mod 40 - path: build/libs/*.jar 36 + name: Armorhud 37 + path: build/libs/
+11 -2
build.gradle
··· 1 1 plugins { 2 - id 'fabric-loom' version '1.6-SNAPSHOT' 2 + id 'fabric-loom' version '1.9-SNAPSHOT' 3 3 id 'maven-publish' 4 4 5 5 } ··· 17 17 // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. 18 18 // See https://docs.gradle.org/current/userguide/declaring_repositories.html 19 19 // for more information about repositories. 20 - maven { url = "https://maven.terraformersmc.com/" } 21 20 // maven { url = "https://maven.gegy.dev" } 21 + maven { 22 + name = "TerraformersMC" 23 + url = "https://maven.terraformersmc.com/" 24 + } 25 + maven { 26 + name = "Ladysnake Libs" 27 + url = 'https://maven.ladysnake.org/releases' 28 + } 22 29 } 23 30 24 31 loom { ··· 48 55 // These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time. 49 56 50 57 // modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}" 58 + 59 + modImplementation "dev.emi:trinkets:${project.trinkets_version}" 51 60 } 52 61 53 62 processResources {
+7 -6
gradle.properties
··· 4 4 5 5 # Fabric Properties 6 6 # check these on https://fabricmc.net/develop 7 - minecraft_version=1.21 8 - yarn_mappings=1.21+build.2 9 - loader_version=0.15.11 7 + minecraft_version=1.21.4 8 + yarn_mappings=1.21.4+build.1 9 + loader_version=0.16.9 10 10 11 11 # Mod Properties 12 - mod_version=1.4.5 12 + mod_version=1.5.1 13 13 maven_group=com.armorhud 14 14 archives_base_name=simple-armor-hud 15 15 16 16 # Dependency properties 17 - fabric_version=0.100.3+1.21 18 - modmenu_version=11.0.1 17 + fabric_version=0.110.5+1.21.4 18 + modmenu_version=13.0.0-beta.1 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.7-bin.zip 3 + distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip 4 4 networkTimeout=10000 5 5 zipStoreBase=GRADLE_USER_HOME 6 6 zipStorePath=wrapper/dists
+14
src/client/java/com/armorhud/armor/ArmorAccessor.java
··· 1 + package com.armorhud.armor; 2 + 3 + import net.minecraft.client.network.ClientPlayerEntity; 4 + import net.minecraft.item.ItemStack; 5 + 6 + public interface ArmorAccessor { 7 + 8 + default void initialize(ClientPlayerEntity player) { 9 + } 10 + 11 + ItemStack getArmorPiece(ClientPlayerEntity player, int slotIndex); 12 + 13 + int getPieces(ClientPlayerEntity player); 14 + }
+90
src/client/java/com/armorhud/armor/TrinketsArmorAccessor.java
··· 1 + package com.armorhud.armor; 2 + 3 + import dev.emi.trinkets.api.SlotReference; 4 + import dev.emi.trinkets.api.TrinketComponent; 5 + import dev.emi.trinkets.api.TrinketsApi; 6 + import java.util.ArrayList; 7 + import java.util.HashMap; 8 + import java.util.List; 9 + import java.util.Map; 10 + import java.util.Optional; 11 + import java.util.function.Function; 12 + import net.minecraft.client.network.ClientPlayerEntity; 13 + import net.minecraft.item.ItemStack; 14 + import net.minecraft.util.Pair; 15 + 16 + public class TrinketsArmorAccessor implements ArmorAccessor { 17 + 18 + private final ArmorAccessor fallback; 19 + private final List<SlotFunction> slotFunctions; 20 + private int pieces; 21 + 22 + public TrinketsArmorAccessor(ArmorAccessor fallback) { 23 + this.fallback = fallback; 24 + this.slotFunctions = new ArrayList<>(); 25 + } 26 + 27 + @Override 28 + public void initialize(ClientPlayerEntity player) { 29 + slotFunctions.clear(); 30 + 31 + // Populate functions with fallback entries first 32 + pieces = fallback.getPieces(player); 33 + for (int i = 0; i < pieces; i++) { 34 + int slot = i; 35 + slotFunctions.add(entity -> fallback.getArmorPiece(entity, slot)); 36 + } 37 + 38 + Optional<TrinketComponent> componentOpt = TrinketsApi.getTrinketComponent(player); 39 + if (componentOpt.isEmpty()) { 40 + return; 41 + } 42 + 43 + TrinketComponent component = componentOpt.get(); 44 + List<Pair<SlotReference, ItemStack>> equipped = component.getEquipped($ -> true); 45 + Map<Integer, Integer> offsetMap = new HashMap<>(); 46 + 47 + // Populate functions with additional trinkets slots 48 + for (int i = 0; i < equipped.size(); i++) { 49 + Pair<SlotReference, ItemStack> pair = equipped.get(i); 50 + int groupSlotIdx = groupToSlot(pair.getLeft().inventory().getSlotType().getGroup()); 51 + int offset = offsetMap.compute(groupSlotIdx, (k, v) -> v == null ? 1 : v + 1); 52 + int slot = i; 53 + slotFunctions.add(groupSlotIdx + offset, entity -> getTrinketsItem(entity, slot)); 54 + } 55 + pieces += equipped.size(); 56 + } 57 + 58 + private ItemStack getTrinketsItem(ClientPlayerEntity player, int idx) { 59 + Optional<TrinketComponent> componentOpt = TrinketsApi.getTrinketComponent(player); 60 + if (componentOpt.isEmpty()) { 61 + return ItemStack.EMPTY; 62 + } 63 + TrinketComponent component = componentOpt.get(); 64 + Pair<SlotReference, ItemStack> pair = component.getEquipped($ -> true).get(idx); 65 + return pair.getRight(); 66 + } 67 + 68 + @Override 69 + public ItemStack getArmorPiece(ClientPlayerEntity player, int slotIndex) { 70 + return slotFunctions.get(slotIndex).apply(player); 71 + } 72 + 73 + @Override 74 + public int getPieces(ClientPlayerEntity player) { 75 + return pieces; 76 + } 77 + 78 + private int groupToSlot(String group) { 79 + return switch (group) { 80 + case "feet" -> 0; 81 + case "legs" -> 1; 82 + case "chest" -> 2; 83 + case "head" -> 3; 84 + default -> -1; 85 + }; 86 + } 87 + 88 + private interface SlotFunction extends Function<ClientPlayerEntity, ItemStack> { 89 + } 90 + }
+20
src/client/java/com/armorhud/armor/VanillaArmorAccessor.java
··· 1 + package com.armorhud.armor; 2 + 3 + import net.minecraft.client.network.ClientPlayerEntity; 4 + import net.minecraft.item.ItemStack; 5 + 6 + public class VanillaArmorAccessor implements ArmorAccessor { 7 + 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); 12 + } 13 + return player.getInventory().getArmorStack(slotIndex); 14 + } 15 + 16 + @Override 17 + public int getPieces(ClientPlayerEntity player) { 18 + return player.getInventory().armor.size(); 19 + } 20 + }
+18 -1
src/client/java/com/armorhud/armorHud.java
··· 1 1 package com.armorhud; 2 2 3 + import com.armorhud.armor.ArmorAccessor; 4 + import com.armorhud.armor.VanillaArmorAccessor; 3 5 import com.armorhud.config.config; 4 6 import com.armorhud.util.armorHudRegistries; 5 7 import net.fabricmc.api.ClientModInitializer; 6 8 import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; 9 + import org.slf4j.Logger; 10 + import org.slf4j.LoggerFactory; 7 11 8 12 public class armorHud implements ClientModInitializer { 9 13 14 + public static final Logger LOGGER = LoggerFactory.getLogger("simple-armor-hud"); 10 15 public static final config CONFIG = new config(); 16 + private static ArmorAccessor armorAccessor; 11 17 12 18 @Override 13 19 public void onInitializeClient() { 14 - System.out.println("Simple Armor Hud loaded!"); 20 + LOGGER.info("Simple Armor Hud loaded!"); 21 + armorAccessor = new VanillaArmorAccessor(); 15 22 CONFIG.load(); 16 23 armorHudRegistries.registerArmorHud(); 17 24 handleKeys(); 25 + 26 + LOGGER.info("Armor accessor implementation: {}", armorAccessor.getClass().getSimpleName()); 18 27 } 19 28 20 29 public void handleKeys() { ··· 23 32 config.ARMOR_HUD = !config.ARMOR_HUD; 24 33 } 25 34 }); 35 + } 36 + 37 + public static void setArmorAccessor(ArmorAccessor armorAccessor) { 38 + armorHud.armorAccessor = armorAccessor; 39 + } 40 + 41 + public static ArmorAccessor getArmorAccessor() { 42 + return armorAccessor; 26 43 } 27 44 }
+3
src/client/java/com/armorhud/config/config.java
··· 15 15 public static boolean ARMOR_HUD = true; 16 16 public static boolean RTL = false; 17 17 public static boolean DISABLE_ARMOR_BAR = false; 18 + public static boolean ABOVE_HEALTH_BAR = false; // a new option to render armor hud above the healthbar instead of the hungerbar -Dino 18 19 19 20 private static final Path CONFIG_PATH = FabricLoader.getInstance().getConfigDir().resolve("armorhud.properties"); 20 21 ··· 24 25 properties.setProperty("armor_hud", Boolean.toString(ARMOR_HUD)); 25 26 properties.setProperty("right_to_left", Boolean.toString(RTL)); 26 27 properties.setProperty("disable_armor_bar", Boolean.toString(DISABLE_ARMOR_BAR)); 28 + properties.setProperty("above_health_bar", Boolean.toString(ABOVE_HEALTH_BAR)); 27 29 } 28 30 29 31 public void read(Properties properties) { ··· 32 34 ARMOR_HUD = Boolean.parseBoolean(properties.getProperty("armor_hud")); 33 35 RTL = Boolean.parseBoolean(properties.getProperty("right_to_left")); 34 36 DISABLE_ARMOR_BAR = Boolean.parseBoolean(properties.getProperty("disable_armor_bar")); 37 + ABOVE_HEALTH_BAR = Boolean.parseBoolean(properties.getProperty("above_health_bar")); 35 38 } 36 39 37 40 public static void save() {
+5 -1
src/client/java/com/armorhud/config/configScreen.java
··· 20 20 public CyclingButtonWidget armorHudToggle; 21 21 public CyclingButtonWidget rightToLeftToggle; 22 22 public CyclingButtonWidget disableArmorBar; 23 + public CyclingButtonWidget aboveHealthBar; // TODO: want the option to visually be "Render: above health bar" & "Render: above hunger bar" instead of "off" & "on" -Dino 23 24 24 25 public ButtonWidget doneButton; 25 26 ··· 40 41 disableArmorBar = CyclingButtonWidget.onOffBuilder(config.DISABLE_ARMOR_BAR) 41 42 .build(Text.translatable("config.disablearmorbar"), ((button, value) -> config.DISABLE_ARMOR_BAR = !config.DISABLE_ARMOR_BAR)); 42 43 44 + aboveHealthBar = CyclingButtonWidget.onOffBuilder(config.ABOVE_HEALTH_BAR) 45 + .build(Text.translatable("config.abovehealthbar"), ((button, value) -> config.ABOVE_HEALTH_BAR = !config.ABOVE_HEALTH_BAR)); 46 + 43 47 OptionListWidget optionListWidget = this.addDrawableChild(new OptionListWidget(this.client, this.width, this)); 44 48 45 49 optionListWidget.addWidgetEntry(doubleHotbarToggle, betterMountHudToggle); 46 50 optionListWidget.addWidgetEntry(armorHudToggle, rightToLeftToggle); 47 - optionListWidget.addWidgetEntry(disableArmorBar, null); 51 + optionListWidget.addWidgetEntry(disableArmorBar, aboveHealthBar); 48 52 49 53 doneButton = ButtonWidget 50 54 .builder(Text.translatable("config.done"), button -> close())
+164 -129
src/client/java/com/armorhud/mixin/client/armorHudMixin.java
··· 1 - package com.armorhud.mixin.client; 2 - 3 - import com.armorhud.config.config; 4 - import net.minecraft.client.MinecraftClient; 5 - import net.minecraft.client.gui.DrawContext; 6 - import net.minecraft.client.gui.hud.InGameHud; 7 - import net.minecraft.client.render.RenderTickCounter; 8 - import net.minecraft.entity.LivingEntity; 9 - import net.minecraft.entity.player.PlayerEntity; 10 - import net.minecraft.item.ItemStack; 11 - import org.spongepowered.asm.mixin.Final; 12 - import org.spongepowered.asm.mixin.Mixin; 13 - import org.spongepowered.asm.mixin.Shadow; 14 - import org.spongepowered.asm.mixin.Unique; 15 - import org.spongepowered.asm.mixin.injection.At; 16 - import org.spongepowered.asm.mixin.injection.Inject; 17 - import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 18 - 19 - @Mixin(InGameHud.class) 20 - public abstract class armorHudMixin { 21 - 22 - @Shadow @Final private MinecraftClient client; 23 - 24 - @Shadow protected abstract LivingEntity getRiddenEntity(); 25 - 26 - @Shadow public abstract void tick(boolean paused); 27 - 28 - @Unique int armorHeight; 29 - 30 - @Inject(at = @At("TAIL"), method = "renderHotbar") 31 - private void renderHud(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) { 32 - if(!config.ARMOR_HUD) { return; } 33 - 34 - assert client.player != null; 35 - 36 - renderArmor(context, tickCounter); 37 - moveArmor(context); 38 - } 39 - 40 - @Unique 41 - private void renderArmor(DrawContext context, RenderTickCounter tickCounter) { 42 - int scaledWidth = context.getScaledWindowWidth(); 43 - 44 - assert client.player != null; 45 - 46 - final int hungerWidth = 80 + 8; // Bar advances 8 pixels to the left 10 times, 8 is added for the width of the last sprite. 47 - final int armorWidth = 15; 48 - final int barWidth = armorWidth * 4; 49 - float hungerX = scaledWidth / 2f + 91; 50 - float x = hungerX - hungerWidth / 2f + barWidth / 2f; 51 - x += 2; // This makes it look better because the helmet is thinner. 52 - 53 - for (int j = 0; j < 4; j++) { 54 - x -= armorWidth; 55 - int armorPiece; 56 - 57 - if (config.RTL) { 58 - armorPiece = 3 - j; 59 - } else { 60 - armorPiece = j; 61 - } 62 - 63 - renderArmorPiece(context, x, armorHeight, tickCounter, client.player, client.player.getInventory().getArmorStack(armorPiece)); 64 - } 65 - } 66 - 67 - // Pretty much the same as renderHotbarItem but with x and y as float parameters. 68 - @Unique 69 - private void renderArmorPiece(DrawContext context, float x, float y, RenderTickCounter tickCounter, PlayerEntity player, ItemStack stack) { 70 - if (stack.isEmpty()) return; 71 - 72 - context.getMatrices().push(); 73 - context.getMatrices().translate(x, y, 0); 74 - 75 - context.drawItem(player, stack, 0, 0, 1); 76 - 77 - context.drawItemInSlot(this.client.textRenderer, stack, 0,0); 78 - context.getMatrices().pop(); 79 - } 80 - 81 - @Unique 82 - private void moveArmor(DrawContext context) { 83 - int scaledHeight = context.getScaledWindowHeight(); 84 - 85 - assert client.player != null; 86 - 87 - // Moves armorhud up if player uses double hotbar 88 - armorHeight = scaledHeight - (config.DOUBLE_HOTBAR ? 76 : 55); 89 - 90 - // Moves armorhud up if player is underwater 91 - if (client.player.getAir() < client.player.getMaxAir() || client.player.isSubmergedInWater() && !client.player.isCreative()) { 92 - armorHeight -= 10; 93 - } 94 - 95 - // Moves armorhud down if player is in creative 96 - armorHeight += (client.player.isCreative() ? 16 : 0); 97 - 98 - // Moves armorhud up if player is on mount, like horse 99 - if (client.player.hasVehicle() && getRiddenEntity() != null) { 100 - moveArmorHorse(); 101 - } 102 - } 103 - 104 - @Unique 105 - private void moveArmorHorse() { 106 - assert client.player != null; 107 - 108 - // Check if entity player is riding is alive, like a horse 109 - if (getRiddenEntity().isAlive()) { 110 - // If horse health is 21, it still displays 10 hearts 111 - if (getRiddenEntity().getMaxHealth() > 21) { 112 - if (config.BETTER_MOUNT_HUD && !client.player.isCreative()) { 113 - armorHeight -= 20; 114 - } else { 115 - armorHeight -= (client.player.isCreative() ? 26 : 10); 116 - } 117 - } 118 - // Armor hud only has to be moved up if better mount hud is enabled or player is in creative 119 - else { 120 - if (config.BETTER_MOUNT_HUD && !client.player.isCreative()) { 121 - armorHeight -= 10; 122 - } else if (client.player.isCreative()) { 123 - armorHeight -= 16; 124 - } 125 - } 126 - } 127 - } 128 - 129 - } 1 + package com.armorhud.mixin.client; 2 + 3 + import com.armorhud.armor.ArmorAccessor; 4 + import com.armorhud.armorHud; 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.render.RenderTickCounter; 10 + import net.minecraft.entity.LivingEntity; 11 + import net.minecraft.entity.player.PlayerEntity; 12 + import net.minecraft.item.ItemStack; 13 + import org.spongepowered.asm.mixin.Final; 14 + import org.spongepowered.asm.mixin.Mixin; 15 + import org.spongepowered.asm.mixin.Shadow; 16 + import org.spongepowered.asm.mixin.Unique; 17 + import org.spongepowered.asm.mixin.injection.At; 18 + import org.spongepowered.asm.mixin.injection.Inject; 19 + import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 20 + 21 + @Mixin(InGameHud.class) 22 + public abstract class armorHudMixin { 23 + 24 + @Shadow @Final private MinecraftClient client; 25 + 26 + @Shadow protected abstract LivingEntity getRiddenEntity(); 27 + 28 + @Shadow public abstract void tick(boolean paused); 29 + 30 + @Unique int armorHeight; 31 + @Unique boolean initialized; 32 + 33 + @Inject(at = @At("TAIL"), method = "renderHotbar") 34 + private void renderHud(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) { 35 + if(!config.ARMOR_HUD) { return; } 36 + 37 + assert client.player != null; 38 + 39 + if (!initialized) { 40 + armorHud.getArmorAccessor().initialize(client.player); 41 + initialized = true; 42 + } 43 + 44 + renderArmor(context, tickCounter); 45 + moveArmor(context); 46 + } 47 + 48 + @Unique 49 + private void renderArmor(DrawContext context, RenderTickCounter tickCounter) { 50 + int scaledWidth = context.getScaledWindowWidth(); 51 + 52 + assert client.player != null; 53 + 54 + ArmorAccessor armorAccessor = armorHud.getArmorAccessor(); 55 + int pieces = armorAccessor.getPieces(client.player); 56 + 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. 58 + final int armorWidth = 15; 59 + final int barWidth = armorWidth * pieces; 60 + // Added check for Above_Health_Bar -Dino 61 + 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; 64 + x += 2; // This makes it look better because the helmet is thinner. 65 + 66 + for (int j = 0; j < pieces; j++) { 67 + x -= armorWidth; 68 + int armorPiece; 69 + 70 + if (config.RTL) { 71 + armorPiece = (pieces - 1) - j; 72 + } else { 73 + armorPiece = j; 74 + } 75 + 76 + renderArmorPiece(context, x, armorHeight, tickCounter, client.player, armorAccessor.getArmorPiece(client.player, armorPiece)); 77 + } 78 + } 79 + 80 + // Pretty much the same as renderHotbarItem but with x and y as float parameters. 81 + @Unique 82 + private void renderArmorPiece(DrawContext context, float x, float y, RenderTickCounter tickCounter, PlayerEntity player, ItemStack stack) { 83 + if (stack.isEmpty()) return; 84 + 85 + context.getMatrices().push(); 86 + context.getMatrices().translate(x, y, 0); 87 + 88 + context.drawItem(player, stack, 0, 0, 1); 89 + 90 + context.drawStackOverlay(this.client.textRenderer, stack, 0,0); 91 + context.getMatrices().pop(); 92 + } 93 + 94 + @Unique 95 + private void moveArmor(DrawContext context) { 96 + int scaledHeight = context.getScaledWindowHeight(); 97 + 98 + assert client.player != null; 99 + 100 + // Moves armorhud up if player uses double hotbar 101 + armorHeight = scaledHeight - (config.DOUBLE_HOTBAR ? 76 : 55); 102 + 103 + /* TODO: fix visual bug where remaining hearts available (>20hp) get removed later than armor hud -Dino 104 + Skips unnecessary checks when Above_Health_Bar is on, not a fan of the extra if statement, but it works -Dino 105 + Note: setting gets turned off above 9 rows of hearts, since the hud will fly off the screen at some point -Dino */ 106 + if (config.ABOVE_HEALTH_BAR && client.player.getMaxHealth() + client.player.getMaxAbsorption() < 180) { 107 + /* Displacement calculation extracted for clarity. -Dino 108 + Calc breaks above 90 hearts since hearts don't get condensed further, so it overshoots down -Dino */ 109 + int playerHealthRows = (int) Math.ceil((client.player.getMaxHealth() + client.player.getMaxAbsorption()) / 20); 110 + int healthDisplacement = (10 * playerHealthRows) - ((playerHealthRows>2) ? (playerHealthRows -2) * (playerHealthRows -1) : 0); 111 + 112 + // Moves armorhud up depending on how much health you have, along with negative displacement from higher heart counts -Dino 113 + armorHeight -= healthDisplacement; 114 + 115 + /* Moves armorhud down if player is in creative or Disable_Armor_Bar is on, 116 + formatted as an if-statement for readability -Dino 117 + */ 118 + if(client.player.isCreative()) { 119 + armorHeight += 16 + healthDisplacement; 120 + } else if (config.DISABLE_ARMOR_BAR) { 121 + armorHeight += 10; 122 + } 123 + } else { 124 + // Moves armorhud up if player is underwater 125 + if ((client.player.getAir() < client.player.getMaxAir() || client.player.isSubmergedInWater() && !client.player.isCreative())) { 126 + armorHeight -= 10; 127 + } 128 + 129 + // Moves armorhud down if player is in creative 130 + armorHeight += (client.player.isCreative() ? 16 : 0); 131 + 132 + // Moves armorhud up if player is on mount, like horse 133 + if (client.player.hasVehicle() && getRiddenEntity() != null) { 134 + moveArmorHorse(); 135 + } 136 + } 137 + } 138 + 139 + @Unique 140 + private void moveArmorHorse() { 141 + assert client.player != null; 142 + 143 + // Check if entity player is riding is alive, like a horse 144 + if (getRiddenEntity().isAlive()) { 145 + // If horse health is 21, it still displays 10 hearts 146 + if (getRiddenEntity().getMaxHealth() > 21) { 147 + if (config.BETTER_MOUNT_HUD && !client.player.isCreative()) { 148 + armorHeight -= 20; 149 + } else { 150 + armorHeight -= (client.player.isCreative() ? 26 : 10); 151 + } 152 + } 153 + // Armor hud only has to be moved up if better mount hud is enabled or player is in creative 154 + else { 155 + if (config.BETTER_MOUNT_HUD && !client.player.isCreative()) { 156 + armorHeight -= 10; 157 + } else if (client.player.isCreative()) { 158 + armorHeight -= 16; 159 + } 160 + } 161 + } 162 + } 163 + 164 + }
+8 -2
src/client/java/com/armorhud/util/modDetect.java
··· 1 1 package com.armorhud.util; 2 2 3 + import com.armorhud.armor.TrinketsArmorAccessor; 4 + import com.armorhud.armorHud; 3 5 import com.armorhud.config.config; 4 6 import net.fabricmc.loader.api.FabricLoader; 5 7 ··· 8 10 public static void detect() { 9 11 if (FabricLoader.getInstance().isModLoaded("bettermounthud")) { 10 12 config.BETTER_MOUNT_HUD = true; 11 - System.out.println("Better mount hud found!"); 13 + armorHud.LOGGER.info("Better mount hud found!"); 12 14 } 13 15 if (FabricLoader.getInstance().isModLoaded("double_hotbar")) { 14 16 config.DOUBLE_HOTBAR = true; 15 - System.out.println("Double hotbar found!"); 17 + armorHud.LOGGER.info("Double hotbar found!"); 18 + } 19 + if (FabricLoader.getInstance().isModLoaded("trinkets")) { 20 + armorHud.setArmorAccessor(new TrinketsArmorAccessor(armorHud.getArmorAccessor())); 21 + armorHud.LOGGER.info("Trinkets found!"); 16 22 } 17 23 18 24 config.save();
+12
src/main/resources/assets/simple-armor-hud/lang/de_de.json
··· 1 + { 2 + "key.armorhud.armorvisible": "Schalte Rüstungs-HUD an/aus", 3 + "category.armorhud.toggles": "Simple armor hud", 4 + 5 + "config.doublehotbar": "Double Hotbar", 6 + "config.bettermounthud": "Better Mount Hud", 7 + "config.armorvisible": "Rüstungs-HUD sichtbar", 8 + "config.disablearmorbar": "Rüstungsbalken ausschalten", 9 + 10 + "config.righttoleft": "Rechts nach links Anzeige", 11 + "config.done": "Fertig" 12 + }
+1
src/main/resources/assets/simple-armor-hud/lang/en_us.json
··· 7 7 "config.armorvisible": "Armor visible", 8 8 "config.righttoleft": "Right to left display", 9 9 "config.disablearmorbar": "Disable armor bar", 10 + "config.abovehealthbar": "Move above health bar", 10 11 11 12 "config.title": "Armor hud config screen", 12 13 "config.done": "Done"
+13
src/main/resources/assets/simple-armor-hud/lang/zh_tw.json
··· 1 + { 2 + "key.armorhud.armorvisible": "開啟/關閉盔甲抬頭顯示器", 3 + "category.armorhud.toggles": "簡易盔甲抬頭顯示器", 4 + 5 + "config.doublehotbar": "雙快捷欄", 6 + "config.bettermounthud": "更佳坐騎抬頭顯示器", 7 + "config.armorvisible": "顯示盔甲", 8 + "config.righttoleft": "從右至左顯示", 9 + "config.disablearmorbar": "停用盔甲條", 10 + 11 + "config.title": "Armor hud《盔甲抬頭顯示器》設定畫面", 12 + "config.done": "完成" 13 + }
+5 -2
src/main/resources/fabric.mod.json
··· 14 14 }, 15 15 "license": "LGPL-2.1", 16 16 "icon": "assets/simple-armor-hud/icon.png", 17 - "environment": "*", 17 + "environment": "client", 18 18 "entrypoints": { 19 19 "client": [ 20 20 "com.armorhud.armorHud" ··· 32 32 "fabricloader": ">=0.14.19", 33 33 "minecraft": ">=1.19", 34 34 "java": ">=17" 35 - } 35 + }, 36 + "suggests": { 37 + "trinkets": ">=3.7.1" 38 + } 36 39 }