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 most recent

legoraft 4c2aa774 7a96d3e1

+130 -106
+10 -12
.github/workflows/build.yml
··· 8 8 9 9 jobs: 10 10 build: 11 - strategy: 12 - matrix: 13 - # Use these Java versions 14 - java: [ 15 - 21, # Current Java LTS 16 - ] 17 - runs-on: ubuntu-22.04 11 + runs-on: ubuntu-24.04 18 12 steps: 19 13 - name: checkout repository 20 14 uses: actions/checkout@v4 15 + 21 16 - name: validate gradle wrapper 22 - uses: gradle/wrapper-validation-action@v2 23 - - name: setup jdk ${{ matrix.java }} 17 + uses: gradle/actions/wrapper-validation@v4 18 + 19 + - name: setup jdk 24 20 uses: actions/setup-java@v4 25 21 with: 26 - java-version: ${{ matrix.java }} 22 + java-version: '21' 27 23 distribution: 'microsoft' 24 + 28 25 - name: make gradle wrapper executable 29 26 run: chmod +x ./gradlew 27 + 30 28 - name: build 31 29 run: ./gradlew build 30 + 32 31 - name: capture build artifacts 33 - if: ${{ matrix.java == '21' }} # Only upload artifacts built from latest java 34 32 uses: actions/upload-artifact@v4 35 33 with: 36 34 name: Armorhud 37 - path: build/libs/ 35 + path: build/libs/
+30 -37
build.gradle
··· 1 1 plugins { 2 - id 'fabric-loom' version "${loom_version}" 2 + id 'net.fabricmc.fabric-loom-remap' version "${loom_version}" 3 3 id 'maven-publish' 4 - 5 4 } 6 5 7 - sourceCompatibility = JavaVersion.VERSION_17 8 - targetCompatibility = JavaVersion.VERSION_17 9 - 10 - archivesBaseName = project.archives_base_name 11 6 version = project.minecraft_version + "-" + project.mod_version 12 7 group = project.maven_group 13 8 9 + base { 10 + archivesName = project.archives_base_name 11 + } 12 + 14 13 repositories { 15 14 // Add repositories to retrieve artifacts from in here. 16 15 // You should only use this when depending on other mods because 17 16 // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. 18 17 // See https://docs.gradle.org/current/userguide/declaring_repositories.html 19 18 // for more information about repositories. 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 - } 19 + maven { 20 + name = "TerraformersMC" 21 + url = "https://maven.terraformersmc.com/" 22 + } 23 + maven { 24 + name = "Ladysnake Libs" 25 + url = 'https://maven.ladysnake.org/releases' 26 + } 29 27 } 30 28 31 29 loom { 32 - splitEnvironmentSourceSets() 30 + splitEnvironmentSourceSets() 33 31 34 - mods { 35 - modid { 36 - sourceSet sourceSets.main 37 - sourceSet sourceSets.client 38 - } 39 - } 32 + mods { 33 + "armorhud" { 34 + sourceSet sourceSets.main 35 + sourceSet sourceSets.client 36 + } 37 + } 40 38 41 39 } 42 40 ··· 50 48 51 49 // Fabric API. This is technically optional, but you probably want it anyway. 52 50 modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" 53 - 54 - // Uncomment the following line to enable the deprecated Fabric API modules. 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. 56 - 57 - // modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}" 58 - 59 - // modImplementation "dev.emi:trinkets:${project.trinkets_version}" 60 51 } 61 52 62 53 processResources { 63 54 inputs.property "version", project.version 64 55 65 56 filesMatching("fabric.mod.json") { 66 - expand "version": project.version 57 + expand "version": inputs.properties.version 67 58 } 68 59 } 69 60 70 61 tasks.withType(JavaCompile).configureEach { 71 - it.options.release = 17 62 + it.options.release = 21 72 63 } 73 64 74 65 java { 75 - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task 76 - // if it is present. 77 - // If you remove this line, sources will not be generated. 66 + sourceCompatibility = JavaVersion.VERSION_21 67 + targetCompatibility = JavaVersion.VERSION_21 78 68 } 79 69 80 70 jar { 71 + inputs.property "archivesName", project.base.archivesName 72 + 81 73 from("LICENSE") { 82 - rename { "${it}_${project.archivesBaseName}"} 74 + rename { "${it}_${inputs.properties.archivesName}"} 83 75 } 84 76 } 85 77 86 78 // configure the maven publication 87 79 publishing { 88 80 publications { 89 - mavenJava(MavenPublication) { 81 + create("mavenJava", MavenPublication) { 82 + artifactId = project.archives_base_name 90 83 from components.java 91 84 } 92 85 } ··· 98 91 // The repositories here will be used for publishing your artifact, not for 99 92 // retrieving dependencies. 100 93 } 101 - } 94 + }
+7 -7
gradle.properties
··· 4 4 5 5 # Fabric Properties 6 6 # check these on https://fabricmc.net/develop 7 - minecraft_version=1.21.7 8 - yarn_mappings=1.21.7+build.2 9 - loader_version=0.16.14 10 - loom_version=1.11-SNAPSHOT 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 11 11 12 12 # Mod Properties 13 - mod_version=1.5.1 13 + mod_version=1.7.0 14 14 maven_group=com.armorhud 15 15 archives_base_name=simple-armor-hud 16 16 17 17 # Dependency properties 18 - fabric_version=0.128.2+1.21.7 19 - modmenu_version=15.0.0-beta.3 18 + fabric_version=0.139.5+1.21.11 19 + modmenu_version=17.0.0-alpha.1 20 20 trinkets_version=3.10.0
gradle/wrapper/gradle-wrapper.jar

This is a binary file and will not be displayed.

+2 -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.14-bin.zip 3 + distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip 4 4 networkTimeout=10000 5 + validateDistributionUrl=true 5 6 zipStoreBase=GRADLE_USER_HOME 6 7 zipStorePath=wrapper/dists
+19 -16
gradlew
··· 1 1 #!/bin/sh 2 2 3 3 # 4 - # Copyright © 2015-2021 the original authors. 4 + # Copyright © 2015 the original authors. 5 5 # 6 6 # Licensed under the Apache License, Version 2.0 (the "License"); 7 7 # you may not use this file except in compliance with the License. ··· 14 14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 15 # See the License for the specific language governing permissions and 16 16 # limitations under the License. 17 + # 18 + # SPDX-License-Identifier: Apache-2.0 17 19 # 18 20 19 21 ############################################################################## ··· 55 57 # Darwin, MinGW, and NonStop. 56 58 # 57 59 # (3) This script is generated from the Groovy template 58 - # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 60 + # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 61 # within the Gradle project. 60 62 # 61 63 # You can find Gradle at https://github.com/gradle/gradle/. ··· 83 85 # This is normally unused 84 86 # shellcheck disable=SC2034 85 87 APP_BASE_NAME=${0##*/} 86 - APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 88 + # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 89 + APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit 87 90 88 91 # Use the maximum available, or set MAX_FD != -1 to use that value. 89 92 MAX_FD=maximum ··· 111 114 NONSTOP* ) nonstop=true ;; 112 115 esac 113 116 114 - CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 115 117 116 118 117 119 # Determine the Java command to use to start the JVM. ··· 130 132 fi 131 133 else 132 134 JAVACMD=java 133 - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 135 + if ! command -v java >/dev/null 2>&1 136 + then 137 + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 134 138 135 139 Please set the JAVA_HOME variable in your environment to match the 136 140 location of your Java installation." 141 + fi 137 142 fi 138 143 139 144 # Increase the maximum file descriptors if we can. ··· 141 146 case $MAX_FD in #( 142 147 max*) 143 148 # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 144 - # shellcheck disable=SC3045 149 + # shellcheck disable=SC2039,SC3045 145 150 MAX_FD=$( ulimit -H -n ) || 146 151 warn "Could not query maximum file descriptor limit" 147 152 esac ··· 149 154 '' | soft) :;; #( 150 155 *) 151 156 # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 152 - # shellcheck disable=SC3045 157 + # shellcheck disable=SC2039,SC3045 153 158 ulimit -n "$MAX_FD" || 154 159 warn "Could not set maximum file descriptor limit to $MAX_FD" 155 160 esac ··· 166 171 # For Cygwin or MSYS, switch paths to Windows format before running java 167 172 if "$cygwin" || "$msys" ; then 168 173 APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 169 - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 170 174 171 175 JAVACMD=$( cygpath --unix "$JAVACMD" ) 172 176 ··· 198 202 # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 199 203 DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 200 204 201 - # Collect all arguments for the java command; 202 - # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 203 - # shell script including quotes and variable substitutions, so put them in 204 - # double quotes to make sure that they get re-expanded; and 205 - # * put everything else in single quotes, so that it's not re-expanded. 205 + # Collect all arguments for the java command: 206 + # * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, 207 + # and any embedded shellness will be escaped. 208 + # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be 209 + # treated as '${Hostname}' itself on the command line. 206 210 207 211 set -- \ 208 212 "-Dorg.gradle.appname=$APP_BASE_NAME" \ 209 - -classpath "$CLASSPATH" \ 210 - org.gradle.wrapper.GradleWrapperMain \ 213 + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ 211 214 "$@" 212 215 213 216 # Stop when "xargs" is not available. ··· 242 245 tr '\n' ' ' 243 246 )" '"$@"' 244 247 245 - exec "$JAVACMD" "$@" 248 + exec "$JAVACMD" "$@"
+13 -12
gradlew.bat
··· 13 13 @rem See the License for the specific language governing permissions and 14 14 @rem limitations under the License. 15 15 @rem 16 + @rem SPDX-License-Identifier: Apache-2.0 17 + @rem 16 18 17 19 @if "%DEBUG%"=="" @echo off 18 20 @rem ########################################################################## ··· 43 45 %JAVA_EXE% -version >NUL 2>&1 44 46 if %ERRORLEVEL% equ 0 goto execute 45 47 46 - echo. 47 - echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 48 - echo. 49 - echo Please set the JAVA_HOME variable in your environment to match the 50 - echo location of your Java installation. 48 + echo. 1>&2 49 + echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 50 + echo. 1>&2 51 + echo Please set the JAVA_HOME variable in your environment to match the 1>&2 52 + echo location of your Java installation. 1>&2 51 53 52 54 goto fail 53 55 ··· 57 59 58 60 if exist "%JAVA_EXE%" goto execute 59 61 60 - echo. 61 - echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 62 - echo. 63 - echo Please set the JAVA_HOME variable in your environment to match the 64 - echo location of your Java installation. 62 + echo. 1>&2 63 + echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 64 + echo. 1>&2 65 + echo Please set the JAVA_HOME variable in your environment to match the 1>&2 66 + echo location of your Java installation. 1>&2 65 67 66 68 goto fail 67 69 68 70 :execute 69 71 @rem Setup the command line 70 72 71 - set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 73 73 74 74 75 @rem Execute Gradle 75 - "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 + "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* 76 77 77 78 :end 78 79 @rem End local scope for the variables with windows NT shell
+3
src/client/java/com/armorhud/config/config.java
··· 16 16 public static boolean RTL = false; 17 17 public static boolean DISABLE_ARMOR_BAR = false; 18 18 public static boolean ABOVE_HEALTH_BAR = false; // a new option to render armor hud above the healthbar instead of the hungerbar -Dino 19 + public static boolean TRIM_EMPTY_SLOTS = false; // toggles trimming space between empty armor slots 19 20 20 21 private static final Path CONFIG_PATH = FabricLoader.getInstance().getConfigDir().resolve("armorhud.properties"); 21 22 ··· 26 27 properties.setProperty("right_to_left", Boolean.toString(RTL)); 27 28 properties.setProperty("disable_armor_bar", Boolean.toString(DISABLE_ARMOR_BAR)); 28 29 properties.setProperty("above_health_bar", Boolean.toString(ABOVE_HEALTH_BAR)); 30 + properties.setProperty("trim_empty_slots", Boolean.toString(TRIM_EMPTY_SLOTS)); 29 31 } 30 32 31 33 public void read(Properties properties) { ··· 35 37 RTL = Boolean.parseBoolean(properties.getProperty("right_to_left")); 36 38 DISABLE_ARMOR_BAR = Boolean.parseBoolean(properties.getProperty("disable_armor_bar")); 37 39 ABOVE_HEALTH_BAR = Boolean.parseBoolean(properties.getProperty("above_health_bar")); 40 + TRIM_EMPTY_SLOTS = Boolean.parseBoolean(properties.getProperty("trim_empty_slots")); 38 41 } 39 42 40 43 public static void save() {
+15 -9
src/client/java/com/armorhud/config/configScreen.java
··· 15 15 this.parent = parent; 16 16 } 17 17 18 - public CyclingButtonWidget doubleHotbarToggle; 19 - public CyclingButtonWidget betterMountHudToggle; 20 - public CyclingButtonWidget armorHudToggle; 21 - public CyclingButtonWidget rightToLeftToggle; 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 18 + public CyclingButtonWidget<?> doubleHotbarToggle; 19 + public CyclingButtonWidget<?> betterMountHudToggle; 20 + public CyclingButtonWidget<?> armorHudToggle; 21 + public CyclingButtonWidget<?> rightToLeftToggle; 22 + public CyclingButtonWidget<?> disableArmorBar; 23 + public CyclingButtonWidget<?> armorPosition; 24 + public CyclingButtonWidget<?> trimEmptySlots; 24 25 25 26 public ButtonWidget doneButton; 26 27 ··· 41 42 disableArmorBar = CyclingButtonWidget.onOffBuilder(config.DISABLE_ARMOR_BAR) 42 43 .build(Text.translatable("config.disablearmorbar"), ((button, value) -> config.DISABLE_ARMOR_BAR = !config.DISABLE_ARMOR_BAR)); 43 44 44 - aboveHealthBar = CyclingButtonWidget.onOffBuilder(config.ABOVE_HEALTH_BAR) 45 - .build(Text.translatable("config.abovehealthbar"), ((button, value) -> config.ABOVE_HEALTH_BAR = !config.ABOVE_HEALTH_BAR)); 45 + armorPosition = CyclingButtonWidget.onOffBuilder(Text.translatable("simple_armor_hud.render.above_food_bar"), 46 + Text.translatable("simple_armor_hud.render.above_armor_bar"), config.ABOVE_HEALTH_BAR) 47 + .build(Text.translatable("config.hudposition"), ((button, value) -> config.ABOVE_HEALTH_BAR = !config.ABOVE_HEALTH_BAR)); 48 + 49 + trimEmptySlots = CyclingButtonWidget.onOffBuilder(config.TRIM_EMPTY_SLOTS) 50 + .build(Text.translatable("config.trimemptyslots"), ((button, value) -> config.TRIM_EMPTY_SLOTS = !config.TRIM_EMPTY_SLOTS)); 46 51 47 52 OptionListWidget optionListWidget = this.addDrawableChild(new OptionListWidget(this.client, this.width, this)); 48 53 49 54 optionListWidget.addWidgetEntry(doubleHotbarToggle, betterMountHudToggle); 50 55 optionListWidget.addWidgetEntry(armorHudToggle, rightToLeftToggle); 51 - optionListWidget.addWidgetEntry(disableArmorBar, aboveHealthBar); 56 + optionListWidget.addWidgetEntry(disableArmorBar, armorPosition); 57 + optionListWidget.addWidgetEntry(trimEmptySlots, null); 52 58 53 59 doneButton = ButtonWidget 54 60 .builder(Text.translatable("config.done"), button -> close())
+6 -6
src/client/java/com/armorhud/keyBindings.java
··· 3 3 import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; 4 4 import net.minecraft.client.option.KeyBinding; 5 5 import net.minecraft.client.util.InputUtil; 6 - import org.lwjgl.glfw.GLFW; 6 + import net.minecraft.util.Identifier; 7 7 8 8 public class keyBindings { 9 9 10 10 public static KeyBinding armorHudToggle; 11 11 12 12 public static void registerKeys() { 13 + final KeyBinding.Category category = KeyBinding.Category.create(Identifier.of("simple-armor-hud", "armorhud.toggles")); 13 14 armorHudToggle = KeyBindingHelper.registerKeyBinding(new KeyBinding( 14 - "key.armorhud.armorvisible", 15 - InputUtil.Type.KEYSYM, 16 - GLFW.GLFW_DONT_CARE, 17 - "category.armorhud.toggles" 18 - )); 15 + "key.armorhud.armorvisible", 16 + InputUtil.UNKNOWN_KEY.getCode(), 17 + category 18 + )); 19 19 } 20 20 21 21 }
+20 -4
src/client/java/com/armorhud/mixin/client/armorHudMixin.java
··· 11 11 import net.minecraft.entity.LivingEntity; 12 12 import net.minecraft.entity.player.PlayerEntity; 13 13 import net.minecraft.item.ItemStack; 14 + import org.slf4j.Logger; 15 + import org.slf4j.LoggerFactory; 14 16 import org.spongepowered.asm.mixin.Final; 15 17 import org.spongepowered.asm.mixin.Mixin; 16 18 import org.spongepowered.asm.mixin.Shadow; ··· 49 51 int scaledWidth = context.getScaledWindowWidth(); 50 52 51 53 assert client.player != null; 52 - 54 + boolean rtl = config.RTL; 53 55 ArmorAccessor armorAccessor = armorHud.getArmorAccessor(); 54 56 55 57 final int hungerWidth = 14; // Magic number to center 4 armor pieces ··· 58 60 // Added check for Above_Health_Bar -Dino 59 61 float hungerX = scaledWidth / 2f + (config.ABOVE_HEALTH_BAR 60 62 && client.player.getMaxHealth() + client.player.getMaxAbsorption() < 180 ? -10 : 91); 61 - float x = hungerX + hungerWidth; 62 - x += 2; // This makes it look better because the helmet is thinner. 63 + EquipmentSlot[] slots = EquipmentSlot.values(); 64 + // 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 65 + int emptyArmorSlots = 0; 66 + if (config.TRIM_EMPTY_SLOTS) { 67 + for (int i = 2; i<6; i++) { // checks players armor slots only. probably makes stuff like trinkets incompatible -dino 68 + if(client.player.getEquippedStack(slots[i]).isEmpty()) { 69 + emptyArmorSlots++; 70 + } 71 + } 72 + } 73 + float x = hungerX + hungerWidth - (7*emptyArmorSlots) + 2; 63 74 64 - for (EquipmentSlot slot : EquipmentSlot.values()) { 75 + 76 + for (int i = rtl ? slots.length-1 : 0; rtl ? i >= 0 : i < slots.length; i += rtl ? -1 : 1) { 77 + EquipmentSlot slot = slots[i]; 78 + if(config.TRIM_EMPTY_SLOTS && slot.getType() == EquipmentSlot.Type.HUMANOID_ARMOR && client.player.getEquippedStack(slot).isEmpty()) { 79 + continue; 80 + }; 65 81 x -= armorWidth; 66 82 67 83 if (slot.isArmorSlot()) {
+5 -2
src/main/resources/assets/simple-armor-hud/lang/en_us.json
··· 1 1 { 2 2 "key.armorhud.armorvisible": "Toggle armor hud on/off", 3 - "category.armorhud.toggles": "Simple armor hud", 3 + "key.category.simple-armor-hud.armorhud.toggles": "Simple armor hud", 4 4 5 5 "config.doublehotbar": "Double Hotbar", 6 6 "config.bettermounthud": "Better Mount Hud", 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 + "config.hudposition": "Render", 11 + "simple_armor_hud.render.above_food_bar": "Above Food Bar", 12 + "simple_armor_hud.render.above_armor_bar": "Above Armor Bar", 13 + "config.trimemptyslots": "Trim Empty Slots", 11 14 12 15 "config.title": "Armor hud config screen", 13 16 "config.done": "Done"