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 #37 from legoraft/dev

Right to left display, mod detection

authored by

Legoraft and committed by
GitHub
08175b5a 6795c4e4

+51 -23
+5 -5
gradle.properties
··· 4 4 5 5 # Fabric Properties 6 6 # check these on https://fabricmc.net/develop 7 - minecraft_version=1.20.2 8 - yarn_mappings=1.20.2+build.4 9 - loader_version=0.14.23 7 + minecraft_version=1.20.4 8 + yarn_mappings=1.20.4+build.1 9 + loader_version=0.15.2 10 10 11 11 # Mod Properties 12 12 mod_version=1.4.1 ··· 14 14 archives_base_name=simple-armor-hud 15 15 16 16 # Dependency properties 17 - fabric_version=0.90.4+1.20.2 18 - modmenu_version=8.0.0 17 + fabric_version=0.91.3+1.20.4 18 + modmenu_version=9.0.0-pre.1 19 19 spruceui_version=5.0.3+1.20.2
+5 -2
src/client/java/com/armorhud/config/config.java
··· 13 13 public static boolean BETTER_MOUNT_HUD = false; 14 14 public static boolean DOUBLE_HOTBAR = false; 15 15 public static boolean ARMOR_HUD = true; 16 + public static boolean RTL = false; 16 17 17 18 private static final Path CONFIG_PATH = FabricLoader.getInstance().getConfigDir().resolve("armorhud.properties"); 18 19 19 - public void write(Properties properties) { 20 + public static void write(Properties properties) { 20 21 properties.setProperty("better_mount_hud", Boolean.toString(BETTER_MOUNT_HUD)); 21 22 properties.setProperty("double_hotbar", Boolean.toString(DOUBLE_HOTBAR)); 22 23 properties.setProperty("armor_hud", Boolean.toString(ARMOR_HUD)); 24 + properties.setProperty("right_to_left", Boolean.toString(RTL)); 23 25 } 24 26 25 27 public void read(Properties properties) { 26 28 BETTER_MOUNT_HUD = Boolean.parseBoolean(properties.getProperty("better_mount_hud")); 27 29 DOUBLE_HOTBAR = Boolean.parseBoolean(properties.getProperty("double_hotbar")); 28 30 ARMOR_HUD = Boolean.parseBoolean(properties.getProperty("armor_hud")); 31 + RTL = Boolean.parseBoolean(properties.getProperty("right_to_left")); 29 32 } 30 33 31 - public void save() { 34 + public static void save() { 32 35 Properties properties = new Properties(); 33 36 write(properties); 34 37 if (!Files.exists(CONFIG_PATH)) {
+4 -12
src/client/java/com/armorhud/config/configScreen.java
··· 1 1 package com.armorhud.config; 2 2 3 - import com.armorhud.armorHud; 4 3 import dev.lambdaurora.spruceui.Position; 5 4 import dev.lambdaurora.spruceui.option.SpruceBooleanOption; 6 5 import dev.lambdaurora.spruceui.option.SpruceOption; ··· 12 11 import net.minecraft.text.Text; 13 12 import org.jetbrains.annotations.Nullable; 14 13 15 - import java.util.Properties; 16 - 17 14 public class configScreen extends SpruceScreen { 18 15 19 16 private final Screen parent; ··· 21 18 private final SpruceOption doubleHotbarToggle; 22 19 private final SpruceOption betterMountHudToggle; 23 20 private final SpruceOption armorHudToggle; 21 + private final SpruceOption rightToLeftToggle; 24 22 25 23 public configScreen(@Nullable Screen parent) { 26 24 super(Text.literal("Armorhud test GUI")); ··· 29 27 this.doubleHotbarToggle = new SpruceBooleanOption("config.doublehotbar", () -> config.DOUBLE_HOTBAR, newValue -> config.DOUBLE_HOTBAR = newValue, Text.translatable("config.description.doublehotbar")); 30 28 this.betterMountHudToggle = new SpruceBooleanOption("config.bettermounthud", () -> config.BETTER_MOUNT_HUD, newValue -> config.BETTER_MOUNT_HUD = newValue, Text.translatable("config.description.bettermounthud")); 31 29 this.armorHudToggle = new SpruceBooleanOption("config.armorvisible", () -> config.ARMOR_HUD, newValue -> config.ARMOR_HUD = newValue, Text.translatable("config.description.armorvisible")); 30 + this.rightToLeftToggle = new SpruceBooleanOption("config.righttoleft", () -> config.RTL, newValue -> config.RTL = newValue, Text.translatable("config.description.righttoleft")); 32 31 } 33 32 34 33 @Override ··· 37 36 38 37 SpruceOptionListWidget list = new SpruceOptionListWidget(Position.of(0, 34), this.width, this.height - 69); 39 38 list.addOptionEntry(this.armorHudToggle, this.doubleHotbarToggle); 40 - list.addOptionEntry(this.betterMountHudToggle, null); 39 + list.addOptionEntry(this.betterMountHudToggle, this.rightToLeftToggle); 41 40 42 41 this.addDrawableChild(list); 43 42 44 - this.addDrawableChild(new SpruceButtonWidget(Position.of(this.width / 2 - 100, this.height - 30), 200, 20, Text.translatable("config.done"), button -> this.applyChanges())); 43 + this.addDrawableChild(new SpruceButtonWidget(Position.of(this.width / 2 - 100, this.height - 30), 200, 20, Text.translatable("config.done"), button -> close())); 45 44 } 46 45 47 46 @Override ··· 55 54 } 56 55 57 56 public void close() { 58 - this.client.setScreen(parent); 59 - } 60 - 61 - public void applyChanges() { 62 - config config = armorHud.CONFIG; 63 - Properties properties = new Properties(); 64 - config.write(properties); 65 57 config.save(); 66 58 this.client.setScreen(parent); 67 59 }
+10 -2
src/client/java/com/armorhud/mixin/client/armorHudMixin.java
··· 38 38 39 39 @Unique 40 40 private void renderArmor(DrawContext context, float tickDelta) { 41 - final int hungerWidth = 80 + 8; // Bar advances 8 pixels to the left 10 times, 8 is added for the with of the last sprite. 41 + final int hungerWidth = 80 + 8; // Bar advances 8 pixels to the left 10 times, 8 is added for the width of the last sprite. 42 42 final int armorWidth = 15; 43 43 final int barWidth = armorWidth * 4; 44 44 float hungerX = scaledWidth / 2f + 91; ··· 47 47 48 48 for (int j = 0; j < 4; j++) { 49 49 x -= armorWidth; 50 - renderArmorPiece(context, x, armorHeight, tickDelta, client.player, client.player.getInventory().getArmorStack(j), 1); 50 + int armorPiece; 51 + 52 + if (config.RTL) { 53 + armorPiece = 3 - j; 54 + } else { 55 + armorPiece = j; 56 + } 57 + 58 + renderArmorPiece(context, x, armorHeight, tickDelta, client.player, client.player.getInventory().getArmorStack(armorPiece), 1); 51 59 } 52 60 } 53 61
+1
src/client/java/com/armorhud/util/armorHudRegistries.java
··· 6 6 7 7 public static void registerArmorHud() { 8 8 keyBindings.registerKeys(); 9 + modDetect.detect(); 9 10 } 10 11 11 12 }
+20
src/client/java/com/armorhud/util/modDetect.java
··· 1 + package com.armorhud.util; 2 + 3 + import com.armorhud.config.config; 4 + import net.fabricmc.loader.api.FabricLoader; 5 + 6 + public class modDetect { 7 + 8 + public static void detect() { 9 + if (FabricLoader.getInstance().isModLoaded("bettermounthud")) { 10 + config.BETTER_MOUNT_HUD = true; 11 + System.out.println("Better mount hud found!"); 12 + } 13 + if (FabricLoader.getInstance().isModLoaded("double_hotbar")) { 14 + config.DOUBLE_HOTBAR = true; 15 + System.out.println("Double hotbar found!"); 16 + } 17 + 18 + config.save(); 19 + } 20 + }
+3 -1
src/main/resources/assets/simple-armor-hud/lang/en_us.json
··· 5 5 "config.doublehotbar": "Double Hotbar", 6 6 "config.bettermounthud": "Better Mount Hud", 7 7 "config.armorvisible": "Armor visible", 8 + "config.righttoleft": "Right to left display", 8 9 "config.done": "Done", 9 10 10 11 "config.description.doublehotbar": "Ensures complatibility between double hotbar and armor hud", 11 12 "config.description.bettermounthud": "Makes better mount hud compatible", 12 - "config.description.armorvisible": "Toggles the visibility of the armor hud" 13 + "config.description.armorvisible": "Toggles the visibility of the armor hud", 14 + "config.description.righttoleft": "Displays the armor from right to left instead of left to right" 13 15 }
+3 -1
src/main/resources/assets/simple-armor-hud/lang/nl_NL.json src/main/resources/assets/simple-armor-hud/lang/nl_nl.json
··· 5 5 "config.doublehotbar": "Double Hotbar", 6 6 "config.bettermounthud": "Better Mount Hud", 7 7 "config.armorvisible": "Harnas-hud zichtbaar", 8 + "config.righttoleft": "Rechts naar links display", 8 9 "config.done": "Gereed", 9 10 10 11 "config.description.doublehotbar": "Zorgt voor compatibiliteit met de double hotbar mod", 11 12 "config.description.bettermounthud": "Maakt armor hud compatibel met de better mount hud mod", 12 - "config.description.armorvisible": "Zet de zichtbaarheid van het harnas aan of uit" 13 + "config.description.armorvisible": "Zet de zichtbaarheid van het harnas aan of uit", 14 + "config.description.righttoleft": "Laat de harnas-hud van rechts naar links zien in plaats van links naar rechts" 13 15 }