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 pull request #38 from legoraft/dev

Added disabling of armor bar through config file

authored by

Legoraft and committed by
GitHub
8f1b20a5 08175b5a

+44 -10
+1 -1
gradle.properties
··· 9 9 loader_version=0.15.2 10 10 11 11 # Mod Properties 12 - mod_version=1.4.1 12 + mod_version=1.4.2 13 13 maven_group=com.armorhud 14 14 archives_base_name=simple-armor-hud 15 15
+3
src/client/java/com/armorhud/config/config.java
··· 14 14 public static boolean DOUBLE_HOTBAR = false; 15 15 public static boolean ARMOR_HUD = true; 16 16 public static boolean RTL = false; 17 + public static boolean DISABLE_ARMOR = false; 17 18 18 19 private static final Path CONFIG_PATH = FabricLoader.getInstance().getConfigDir().resolve("armorhud.properties"); 19 20 ··· 22 23 properties.setProperty("double_hotbar", Boolean.toString(DOUBLE_HOTBAR)); 23 24 properties.setProperty("armor_hud", Boolean.toString(ARMOR_HUD)); 24 25 properties.setProperty("right_to_left", Boolean.toString(RTL)); 26 + properties.setProperty("disable_armor", Boolean.toString(DISABLE_ARMOR)); 25 27 } 26 28 27 29 public void read(Properties properties) { ··· 29 31 DOUBLE_HOTBAR = Boolean.parseBoolean(properties.getProperty("double_hotbar")); 30 32 ARMOR_HUD = Boolean.parseBoolean(properties.getProperty("armor_hud")); 31 33 RTL = Boolean.parseBoolean(properties.getProperty("right_to_left")); 34 + DISABLE_ARMOR = Boolean.parseBoolean(properties.getProperty("disable_armor")); 32 35 } 33 36 34 37 public static void save() {
+30
src/client/java/com/armorhud/mixin/client/inGameHudMixin.java
··· 1 + package com.armorhud.mixin.client; 2 + 3 + import com.armorhud.config.config; 4 + import net.minecraft.client.gui.hud.InGameHud; 5 + import net.minecraft.entity.player.PlayerEntity; 6 + import org.jetbrains.annotations.Nullable; 7 + import org.spongepowered.asm.mixin.Mixin; 8 + import org.spongepowered.asm.mixin.Shadow; 9 + import org.spongepowered.asm.mixin.injection.At; 10 + import org.spongepowered.asm.mixin.injection.ModifyVariable; 11 + 12 + @Mixin(InGameHud.class) 13 + 14 + public abstract class inGameHudMixin { 15 + 16 + @Shadow @Nullable protected abstract PlayerEntity getCameraPlayer(); 17 + 18 + @ModifyVariable(method = "renderStatusBars", at = @At("STORE"), ordinal = 11) 19 + public int renderStatusBars(int u) { 20 + PlayerEntity playerEntity = this.getCameraPlayer(); 21 + assert playerEntity != null; 22 + 23 + if (config.DISABLE_ARMOR) { 24 + return 0; 25 + } else { 26 + return playerEntity.getArmor(); 27 + } 28 + } 29 + 30 + }
+10 -9
src/client/resources/simple-armor-hud.client.mixins.json
··· 1 1 { 2 - "required": true, 3 - "package": "com.armorhud.mixin.client", 4 - "compatibilityLevel": "JAVA_17", 5 - "client": [ 6 - "armorHudMixin", 7 - "tooltipMixin" 8 - ], 9 - "injectors": { 10 - "defaultRequire": 1 2 + "required": true, 3 + "package": "com.armorhud.mixin.client", 4 + "compatibilityLevel": "JAVA_17", 5 + "client": [ 6 + "armorHudMixin", 7 + "inGameHudMixin", 8 + "tooltipMixin" 9 + ], 10 + "injectors": { 11 + "defaultRequire": 1 11 12 } 12 13 }