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.

updating to new file structure

authored by

Legoraft and committed by
GitHub
3cf52915 098a03b3

-130
-13
src/main/java/net/legoraft/armorhud/armorHud.java
··· 1 - package net.legoraft.armorhud; 2 - 3 - import net.fabricmc.api.ModInitializer; 4 - 5 - public class armorHud implements ModInitializer { 6 - 7 - @Override 8 - public void onInitialize() { 9 - 10 - System.out.println("Simple armor hud loaded!"); 11 - 12 - } 13 - }
-66
src/main/java/net/legoraft/armorhud/mixin/hudMixin.java
··· 1 - package net.legoraft.armorhud.mixin; 2 - 3 - import net.minecraft.client.MinecraftClient; 4 - import net.minecraft.client.gui.hud.InGameHud; 5 - import net.minecraft.client.util.math.MatrixStack; 6 - import net.minecraft.entity.LivingEntity; 7 - import net.minecraft.entity.player.PlayerEntity; 8 - import net.minecraft.item.ItemStack; 9 - import org.spongepowered.asm.mixin.Final; 10 - import org.spongepowered.asm.mixin.Mixin; 11 - import org.spongepowered.asm.mixin.Shadow; 12 - import org.spongepowered.asm.mixin.injection.At; 13 - import org.spongepowered.asm.mixin.injection.Inject; 14 - import org.spongepowered.asm.mixin.injection.ModifyVariable; 15 - import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 16 - 17 - @Mixin(InGameHud.class) 18 - public abstract class hudMixin { 19 - 20 - @Shadow @Final private MinecraftClient client; 21 - @Shadow private int scaledWidth; 22 - @Shadow private int scaledHeight; 23 - @Shadow protected abstract void renderHotbarItem(int x, int y, float tickDelta, PlayerEntity player, ItemStack stack, int seed); 24 - 25 - @Shadow protected abstract LivingEntity getRiddenEntity(); 26 - 27 - @Inject(at = @At("HEAD"), method = "renderHotbar") 28 - public void renderArmorHud(float tickDelta, MatrixStack matrices, CallbackInfo ci) { 29 - assert this.client.player != null; 30 - 31 - int i = this.scaledHeight - 55; 32 - int h = 63; 33 - 34 - // Moves armorhud up if player is under water 35 - if (client.player.getAir() < client.player.getMaxAir()) { 36 - i = this.scaledHeight - 65; 37 - } 38 - // Moves armorhud down if player is in creative 39 - if (client.player.isCreative()) { 40 - i = this.scaledHeight - 39; 41 - } 42 - // Moves armorhud up if player is on mount 43 - if (client.player.hasVehicle() && getRiddenEntity() != null) { 44 - if (getRiddenEntity().isAlive()) { 45 - if (getRiddenEntity().getMaxHealth() > 20) { 46 - i = this.scaledHeight - 65; 47 - } 48 - else { 49 - i = this.scaledHeight - 55; 50 - } 51 - } 52 - } 53 - 54 - // Render all armor items from player 55 - for (int j = 0; j < 4; j++) { 56 - this.renderHotbarItem(this.scaledWidth / 2 + h, i, tickDelta, client.player, this.client.player.getInventory().getArmorStack(j), 1); 57 - h = h - 15; 58 - } 59 - } 60 - 61 - @ModifyVariable(at = @At("STORE"), method = "renderHeldItemTooltip", ordinal = 2) 62 - public int renderHeldItemTooltip(int k) { 63 - return this.scaledHeight - 62; 64 - } 65 - 66 - }
-14
src/main/resources/armorhud.mixins.json
··· 1 - { 2 - "required": true, 3 - "minVersion": "0.8", 4 - "package": "net.legoraft.armorhud.mixin", 5 - "compatibilityLevel": "JAVA_17", 6 - "mixins": [ 7 - ], 8 - "client": [ 9 - "hudMixin" 10 - ], 11 - "injectors": { 12 - "defaultRequire": 1 13 - } 14 - }
src/main/resources/assets/armorhud/icon.png

This is a binary file and will not be displayed.

-37
src/main/resources/fabric.mod.json
··· 1 - { 2 - "schemaVersion": 1, 3 - "id": "armorhud", 4 - "version": "${version}", 5 - 6 - "name": "Simple armor hud", 7 - "description": "A simple mod that adds your armor to the hud above the food bar", 8 - "authors": [ 9 - "LegoRaft" 10 - ], 11 - "contact": { 12 - "homepage": "https://github.com/LegoRaft/simple-armor-hud", 13 - "sources": "https://github.com/LegoRaft/simple-armor-hud" 14 - }, 15 - 16 - "license": "GPL-3.0", 17 - "icon": "assets/armorhud/icon.png", 18 - 19 - "environment": "*", 20 - "entrypoints": { 21 - "main": [ 22 - "net.legoraft.armorhud.armorHud" 23 - ] 24 - }, 25 - "mixins": [ 26 - "armorhud.mixins.json" 27 - ], 28 - 29 - "depends": { 30 - "fabricloader": ">=0.11.3", 31 - "minecraft": "1.19.x", 32 - "java": ">=17" 33 - }, 34 - "suggests": { 35 - "another-mod": "*" 36 - } 37 - }