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.

added new file structure with split client

authored by

Legoraft and committed by
GitHub
e02eba82 3cf52915

+146
+67
src/client/java/com/armorhud/mixin/client/armorHudMixin.java
··· 1 + package com.armorhud.mixin.client; 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.callback.CallbackInfo; 15 + 16 + @Mixin(InGameHud.class) 17 + 18 + public abstract class armorHudMixin { 19 + 20 + @Shadow protected abstract void renderHotbarItem(MatrixStack matrixStack, int i, int j, float f, PlayerEntity playerEntity, ItemStack itemStack, int k); 21 + 22 + @Shadow @Final private MinecraftClient client; 23 + 24 + @Shadow private int scaledWidth; 25 + 26 + @Shadow private int scaledHeight; 27 + 28 + @Shadow protected abstract LivingEntity getRiddenEntity(); 29 + 30 + @Inject(at = @At("HEAD"), method = "render") 31 + 32 + private void renderHud(MatrixStack matrices, float tickDelta, CallbackInfo ci) { 33 + 34 + assert client.player != null; 35 + 36 + int h = 68; 37 + int i = this.scaledHeight - 55; 38 + 39 + // Moves armorhud up if player is underwater 40 + if (client.player.getAir() < client.player.getMaxAir()) { 41 + i = this.scaledHeight - 65; 42 + } 43 + // Moves armorhud down if player is in creative 44 + if (client.player.isCreative()) { 45 + i = this.scaledHeight - 39; 46 + } 47 + // Moves armorhud up if player is on mount 48 + if (client.player.hasVehicle() && getRiddenEntity() != null) { 49 + if (getRiddenEntity().isAlive()) { 50 + if (getRiddenEntity().getMaxHealth() > 20) { 51 + i = this.scaledHeight - 65; 52 + } 53 + else { 54 + i = this.scaledHeight - 55; 55 + } 56 + } 57 + } 58 + 59 + // Render all armor items from player 60 + for (int j = 0; j < 4; j++) { 61 + renderHotbarItem(matrices, this.scaledWidth / 2 + h, i, tickDelta, client.player, client.player.getInventory().getArmorStack(j), 1); 62 + h -= 15; 63 + } 64 + 65 + } 66 + 67 + }
+20
src/client/java/com/armorhud/mixin/client/tooltipMixin.java
··· 1 + package com.armorhud.mixin.client; 2 + 3 + import net.minecraft.client.gui.hud.InGameHud; 4 + import org.spongepowered.asm.mixin.Mixin; 5 + import org.spongepowered.asm.mixin.Shadow; 6 + import org.spongepowered.asm.mixin.injection.At; 7 + import org.spongepowered.asm.mixin.injection.ModifyVariable; 8 + 9 + @Mixin(InGameHud.class) 10 + 11 + public abstract class tooltipMixin { 12 + 13 + @Shadow private int scaledHeight; 14 + 15 + @ModifyVariable(method = "renderHeldItemTooltip", at = @At("STORE"), ordinal = 2) 16 + public int renderHeldItemTooltip(int k) { 17 + return this.scaledHeight - 62; 18 + } 19 + 20 + }
+12
src/client/resources/simple-armor-hud.client.mixins.json
··· 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 11 + } 12 + }
src/main/resources/assets/simple-armor-hud/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": "simple-armor-hud", 4 + "version": "${version}", 5 + "name": "Simple armor hud", 6 + "description": "A simple mod that adds your armor to the hud above the food bar", 7 + "authors": [ 8 + "LegoRaft" 9 + ], 10 + "contact": { 11 + "homepage": "https://github.com/LegoRaft/simple-armor-hud", 12 + "sources": "https://github.com/LegoRaft/simple-armor-hud", 13 + "issues": "https://github.com/LegoRaft/simple-armor-hud/issues" 14 + }, 15 + "license": "GPL-3.0", 16 + "icon": "assets/simple-armor-hud/icon.png", 17 + "environment": "*", 18 + "entrypoints": { 19 + "client": [ 20 + ] 21 + }, 22 + "mixins": [ 23 + "simple-armor-hud.mixins.json", 24 + { 25 + "config": "simple-armor-hud.client.mixins.json", 26 + "environment": "client" 27 + } 28 + ], 29 + "depends": { 30 + "fabricloader": ">=0.14.19", 31 + "minecraft": "~1.19.4", 32 + "java": ">=17" 33 + }, 34 + "suggests": { 35 + "another-mod": "*" 36 + } 37 + }
+10
src/main/resources/simple-armor-hud.mixins.json
··· 1 + { 2 + "required": true, 3 + "package": "com.armorhud.mixin", 4 + "compatibilityLevel": "JAVA_17", 5 + "mixins": [ 6 + ], 7 + "injectors": { 8 + "defaultRequire": 1 9 + } 10 + }