From 93062cd3c6aa1c1e86376458211a7a9d950d5be4 Mon Sep 17 00:00:00 2001 From: Awsome-Creeper9 Date: Wed, 1 Jul 2026 00:22:27 -0500 Subject: [PATCH 1/3] Added Damage Direction Indicator --- .../config/ModMenuIntegration.java | 12 +++- .../hud/DamageIndicatorHudRenderer.java | 66 +++++++++++++++++ .../lemclienthelper/hud/HudConfig.java | 4 ++ .../lemclienthelper/hud/HudMod.java | 67 ++++++++++++++++++ .../DamageIndicator/DamageAngleMixin.java | 25 +++++++ .../assets/lemclienthelper/lang/en_us.json | 10 ++- .../textures/hud/damage_indicator_0.png | Bin 0 -> 380 bytes .../textures/hud/damage_indicator_1.png | Bin 0 -> 371 bytes .../textures/hud/damage_indicator_2.png | Bin 0 -> 377 bytes .../textures/hud/damage_indicator_3.png | Bin 0 -> 372 bytes .../textures/hud/damage_indicator_4.png | Bin 0 -> 369 bytes .../textures/hud/damage_indicator_5.png | Bin 0 -> 382 bytes .../textures/hud/damage_indicator_6.png | Bin 0 -> 373 bytes .../textures/hud/damage_indicator_7.png | Bin 0 -> 378 bytes .../textures/hud/damage_indicator_full.png | Bin 0 -> 399 bytes src/main/resources/fabric.mod.json | 3 +- .../resources/lemclienthelper.mixins.json | 3 +- 17 files changed, 186 insertions(+), 4 deletions(-) create mode 100644 src/main/java/net/kyrptonaught/lemclienthelper/hud/DamageIndicatorHudRenderer.java create mode 100644 src/main/java/net/kyrptonaught/lemclienthelper/mixin/DamageIndicator/DamageAngleMixin.java create mode 100644 src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_0.png create mode 100644 src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_1.png create mode 100644 src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_2.png create mode 100644 src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_3.png create mode 100644 src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_4.png create mode 100644 src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_5.png create mode 100644 src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_6.png create mode 100644 src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_7.png create mode 100644 src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_full.png diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/config/ModMenuIntegration.java b/src/main/java/net/kyrptonaught/lemclienthelper/config/ModMenuIntegration.java index 6a67a80..be2ae6f 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/config/ModMenuIntegration.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/config/ModMenuIntegration.java @@ -80,7 +80,7 @@ public ConfigScreenFactory getModConfigScreenFactory() { panItem.setToolTipWithNewLine("key.lemclienthelper.serverconfig.panscale.tooltip"); - //Hud + //Armor Hud HudConfig clientGUI = HudMod.getConfig(); ConfigSection clientGUISection = new ConfigSection(configScreen, Text.translatable("key.lemclienthelper.clientgui")); @@ -104,6 +104,16 @@ public ConfigScreenFactory getModConfigScreenFactory() { //clientGUISection.addConfigItem(new ArmorHudPreviewItem(Text.translatable("key.lemclienthelper.clientgui.displaypreview"), clientGUI.enabled, false)); + // Damage Indicator + ConfigSection damageIndicatorSection = new ConfigSection(configScreen, Text.translatable("key.lemclienthelper.damageindicator")); + + damageIndicatorSection.addConfigItem(new BooleanItem(Text.translatable("key.lemclienthelper.damageindicator.enabled"), clientGUI.enableDamageIndicator, true).setSaveConsumer(val -> clientGUI.enableDamageIndicator = val)); + + IntegerItem damageIndicatorFadeOut = (IntegerItem) damageIndicatorSection.addConfigItem(new IntegerItem(Text.translatable("key.lemclienthelper.damageindicator.fadeout"), clientGUI.damageIndicatorFadeOut, 16)); + damageIndicatorFadeOut.setMinMax(0, 200); + damageIndicatorFadeOut.setSaveConsumer(val -> clientGUI.damageIndicatorFadeOut = val); + damageIndicatorFadeOut.setToolTipWithNewLine("key.lemclienthelper.damageindicator.fadeout.tooltip"); + //Small Inv ConfigSection smallInvSection = new ConfigSection(configScreen, Text.translatable("key.lemclienthelper.smallinv")); diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/hud/DamageIndicatorHudRenderer.java b/src/main/java/net/kyrptonaught/lemclienthelper/hud/DamageIndicatorHudRenderer.java new file mode 100644 index 0000000..f26ec9f --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/hud/DamageIndicatorHudRenderer.java @@ -0,0 +1,66 @@ +package net.kyrptonaught.lemclienthelper.hud; + +import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.render.*; +import net.minecraft.util.Identifier; +import org.joml.Matrix4f; + +import java.util.List; + +public class DamageIndicatorHudRenderer { + private static final Identifier[] INDICATORS = new Identifier[]{ + new Identifier("lemclienthelper", "textures/hud/damage_indicator_0.png"), + new Identifier("lemclienthelper", "textures/hud/damage_indicator_1.png"), + new Identifier("lemclienthelper", "textures/hud/damage_indicator_2.png"), + new Identifier("lemclienthelper", "textures/hud/damage_indicator_3.png"), + new Identifier("lemclienthelper", "textures/hud/damage_indicator_4.png"), + new Identifier("lemclienthelper", "textures/hud/damage_indicator_5.png"), + new Identifier("lemclienthelper", "textures/hud/damage_indicator_6.png"), + new Identifier("lemclienthelper", "textures/hud/damage_indicator_7.png") + }; + + public static void onHudRender(DrawContext context, float v) { + MinecraftClient client = MinecraftClient.getInstance(); + if (client.player != null && HudMod.shouldDisplayDmgIndicator()) { + int height = client.getWindow().getScaledHeight(); + int width = client.getWindow().getScaledWidth(); + + context.getMatrices().push(); + context.getMatrices().translate(width / 2f, height / 2f, 0); + context.getMatrices().scale(1f, 1f, 1f); + context.getMatrices().translate(-8.5, -8, 0); + context.setShaderColor(1f, 1f, 1f, 1f); + + if (HudMod.shouldDisplayDmgIndicator()) { + int[] time = HudMod.getDMGTimeAngle(); + draw(context, INDICATORS[0], 0, 0, Math.max(1 - (time[0] / ((float) HudMod.getConfig().damageIndicatorFadeOut)), 0)); + draw(context, INDICATORS[1], 0, 0, Math.max(1 - (time[1] / ((float) HudMod.getConfig().damageIndicatorFadeOut)), 0)); + draw(context, INDICATORS[2], 0, 0, Math.max(1 - (time[2] / ((float) HudMod.getConfig().damageIndicatorFadeOut)), 0)); + draw(context, INDICATORS[3], 0, 0, Math.max(1 - (time[3] / ((float) HudMod.getConfig().damageIndicatorFadeOut)), 0)); + draw(context, INDICATORS[4], 0, 0, Math.max(1 - (time[4] / ((float) HudMod.getConfig().damageIndicatorFadeOut)), 0)); + draw(context, INDICATORS[5], 0, 0, Math.max(1 - (time[5] / ((float) HudMod.getConfig().damageIndicatorFadeOut)), 0)); + draw(context, INDICATORS[6], 0, 0, Math.max(1 - (time[6] / ((float) HudMod.getConfig().damageIndicatorFadeOut)), 0)); + draw(context, INDICATORS[7], 0, 0, Math.max(1 - (time[7] / ((float) HudMod.getConfig().damageIndicatorFadeOut)), 0)); + } + context.setShaderColor(1f, 1f, 1f, 1f); + context.getMatrices().pop(); + } + } + + private static void draw(DrawContext context, Identifier texture, float x, float y, float alpha) { + RenderSystem.setShaderTexture(0, texture); + RenderSystem.setShader(GameRenderer::getPositionColorTexProgram); + RenderSystem.enableBlend(); + Matrix4f matrix4f = context.getMatrices().peek().getPositionMatrix(); + BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer(); + bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR_TEXTURE); + bufferBuilder.vertex(matrix4f, x, y, 0f).color(1f, 1f, 1f, alpha).texture(0f, 0f).next(); + bufferBuilder.vertex(matrix4f, x, y + 16, 0f).color(1, 1f, 1f, alpha).texture(0f, 1f).next(); + bufferBuilder.vertex(matrix4f, x + 16, y + 16, 0f).color(1f, 1f, 1f, alpha).texture(1f, 1f).next(); + bufferBuilder.vertex(matrix4f, x + 16, y, 0f).color(1f, 1f, 1f, alpha).texture(1f, 0f).next(); + BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); + RenderSystem.disableBlend(); + } +} diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/hud/HudConfig.java b/src/main/java/net/kyrptonaught/lemclienthelper/hud/HudConfig.java index bcc740d..ba41314 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/hud/HudConfig.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/hud/HudConfig.java @@ -12,4 +12,8 @@ public class HudConfig implements AbstractConfigFile { public float xOffset = 20; public float transparency =.75f; + + public boolean enableDamageIndicator = true; + + public int damageIndicatorFadeOut = 16; } diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/hud/HudMod.java b/src/main/java/net/kyrptonaught/lemclienthelper/hud/HudMod.java index 47679cc..19527a6 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/hud/HudMod.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/hud/HudMod.java @@ -1,10 +1,12 @@ package net.kyrptonaught.lemclienthelper.hud; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; import net.kyrptonaught.lemclienthelper.LEMClientHelperMod; import net.minecraft.util.Identifier; +import java.util.Arrays; public class HudMod { public static String MOD_ID = "hud"; @@ -13,6 +15,8 @@ public class HudMod { private static final Identifier ARMOR_HUD_DISABLE = new Identifier("armorhud", "armor_hud_render_disable"); public static boolean SHOULD_RENDER_ARMOR = false; + public static float DMG_ANGLE = 0; + public static int[] DMG_TIME_ANGLE = {100, 100, 100, 100, 100, 100, 100, 100}; public static void onInitialize() { @@ -20,17 +24,80 @@ public static void onInitialize() { LEMClientHelperMod.configManager.load(MOD_ID); //register hud's here HudRenderCallback.EVENT.register(ArmorHudRenderer::onHudRender); + HudRenderCallback.EVENT.register(DamageIndicatorHudRenderer::onHudRender); + + for (int i = 0; i < DMG_TIME_ANGLE.length; i++) { + DMG_TIME_ANGLE[i] = getConfig().damageIndicatorFadeOut; + } ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> SHOULD_RENDER_ARMOR = false); ClientPlayNetworking.registerGlobalReceiver(ARMOR_HUD_ENABLE, (client, handler, buf, responseSender) -> SHOULD_RENDER_ARMOR = true); ClientPlayNetworking.registerGlobalReceiver(ARMOR_HUD_DISABLE, (client, handler, buf, responseSender) -> SHOULD_RENDER_ARMOR = false); + ClientTickEvents.END_CLIENT_TICK.register(client -> {onClientTick();}); + } + + public static void onClientTick() { + for (int i = 0; i < DMG_TIME_ANGLE.length; i++) { + if (DMG_TIME_ANGLE[i] < getConfig().damageIndicatorFadeOut) { + DMG_TIME_ANGLE[i]++; + } + } } public static boolean shouldDisplay() { return getConfig().alwaysEnabled || SHOULD_RENDER_ARMOR; } + public static boolean shouldDisplayDmgIndicator() { + return getConfig().enableDamageIndicator; + } + + public static float getDMGAngle() { + return DMG_ANGLE; + } + + public static void setDMGAngle(float angle) { + DMG_ANGLE = angle; + } + + public static void resetTimeForAngle(float angle) { + if (Math.abs(angle) <= (45.0/2.0)) { + DMG_TIME_ANGLE[1] = 0; + } + else if (Math.abs(angle) <= 45.0 + (45.0/2.0)) { + if (angle < 0) { + DMG_TIME_ANGLE[2] = 0; + } + else { + DMG_TIME_ANGLE[0] = 0; + } + } + else if (Math.abs(angle) <= 90.0 + (45.0/2.0)) { + if (angle < 0) { + DMG_TIME_ANGLE[4] = 0; + } + else { + DMG_TIME_ANGLE[3] = 0; + } + } + else if (Math.abs(angle) <= 180.0 - (45.0/2.0)) { + if (angle < 0) { + DMG_TIME_ANGLE[7] = 0; + } + else { + DMG_TIME_ANGLE[5] = 0; + } + } + else { + DMG_TIME_ANGLE[6] = 0; + } + } + + public static int[] getDMGTimeAngle() { + return Arrays.copyOf(DMG_TIME_ANGLE, DMG_TIME_ANGLE.length); + } + public static HudConfig getConfig() { return (HudConfig) LEMClientHelperMod.configManager.getConfig(MOD_ID); } diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/DamageIndicator/DamageAngleMixin.java b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/DamageIndicator/DamageAngleMixin.java new file mode 100644 index 0000000..1265c1f --- /dev/null +++ b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/DamageIndicator/DamageAngleMixin.java @@ -0,0 +1,25 @@ +package net.kyrptonaught.lemclienthelper.mixin.DamageIndicator; + +import net.kyrptonaught.lemclienthelper.hud.HudMod; +import net.minecraft.entity.LivingEntity; +import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.util.math.MathHelper; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(LivingEntity.class) +public abstract class DamageAngleMixin { + @Inject(method = "animateDamage", at = @At("HEAD")) + private void onAnimateDamage(float yaw, CallbackInfo ci) { + // Ensure this logic only runs for the local player on the client + if ((Object)this instanceof ClientPlayerEntity player) { + // Fix MC related stupidity: + float angle = MathHelper.wrapDegrees(-yaw + 90); + + HudMod.setDMGAngle(angle); + HudMod.resetTimeForAngle(angle); + } + } +} diff --git a/src/main/resources/assets/lemclienthelper/lang/en_us.json b/src/main/resources/assets/lemclienthelper/lang/en_us.json index dba56c1..941e66e 100644 --- a/src/main/resources/assets/lemclienthelper/lang/en_us.json +++ b/src/main/resources/assets/lemclienthelper/lang/en_us.json @@ -30,6 +30,10 @@ "key.lemclienthelper.clientgui.xOffset.tooltip": "Sets the X Offset the Armor HUD will be rendered at.\nValues between 0-100.", "key.lemclienthelper.clientgui.transparency": "Armor HUD Transparency", "key.lemclienthelper.clientgui.transparency.tooltip": "Sets the transparency the Armor HUD will be rendered at.\nValues between 0.0-1.0.", + "key.lemclienthelper.damageindicator": "Damage Direction Indicator", + "key.lemclienthelper.damageindicator.enabled":"Enable Damage Direction Indicator", + "key.lemclienthelper.damageindicator.fadeout": "Fadeout Time", + "key.lemclienthelper.damageindicator.fadeout.tooltip": "Sets the fade out time (in ticks) for the damage direction indicator.\nValues between 0-200.", "key.lemclienthelper.syncedkeybinds": "Synced Keybinds", "key.lemclienthelper.syncedkeys": "Synced Keys", "key.lemclienthelper.syncedkeys.tooltip": "These are keybindings synced from a LEM server\nOnly functional on LEM servers", @@ -37,5 +41,9 @@ "key.lemclienthelper.serverconfig.guiscale": "GUI Scale", "key.lemclienthelper.serverconfig.panscale": "Panorama Scale", "key.lemclienthelper.serverconfig.guiscale.tooltip": "Sets your GUI Scale 1-4 on official LEM servers.\nSetting this value to 0 will use your option set on the server", - "key.lemclienthelper.serverconfig.panscale.tooltip": "Sets your Panorama Scale 1-4 on official LEM servers.\nSetting this value to 0 will use your option set on the server" + "key.lemclienthelper.serverconfig.panscale.tooltip": "Sets your Panorama Scale 1-4 on official LEM servers.\nSetting this value to 0 will use your option set on the server", + "key.lemclienthelper.autogg": "Auto GG", + "key.lemclienthelper.autogg.enabled": "Enabled", + "key.lemclienthelper.autogg.message": "Message", + "key.lemclienthelper.autogg.delay": "Delay (in ticks)" } \ No newline at end of file diff --git a/src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_0.png b/src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_0.png new file mode 100644 index 0000000000000000000000000000000000000000..fd39f19bfb6b23c5b812997244e0126867532af0 GIT binary patch literal 380 zcmeAS@N?(olHy`uVBq!ia0vp^{2-A-dE?mA3WNLW2IEGmGC;vHr;KO`IP6HzY1EtR&nM%$s nVNfe!3}SGd<$h2@;s^u7RUQ_Wb?Z&EK>9sh{an^LB{Ts5C$dL| literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_1.png b/src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_1.png new file mode 100644 index 0000000000000000000000000000000000000000..f7c38279590fe80349dbf127080600b7be0a10f6 GIT binary patch literal 371 zcmeAS@N?(olHy`uVBq!ia0vp^{2-A-dE?mA3WXgNGIEGmGC#M`>`e$tL$6Y)*B_Y8@T$*)p cf=GZgP(eBq)6KgZK*7u4>FVdQ&MBb@091-XZU6uP literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_2.png b/src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_2.png new file mode 100644 index 0000000000000000000000000000000000000000..8a4c7b6b1f0e2f2f0410478e8ede38414d4013e9 GIT binary patch literal 377 zcmeAS@N?(olHy`uVBq!ia0vp^{2-A-dE?mA3WU6|)IEGmGC#NVd{z*^x(XZzw_T&745A!)= jCx|#qd=_ZH#b(IBz;>C1Nuy2R3rMr4tDnm{r-UW|P54H) literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_3.png b/src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_3.png new file mode 100644 index 0000000000000000000000000000000000000000..9554389d5efb2d49595841966b05fddbddfa1b7c GIT binary patch literal 372 zcmeAS@N?(olHy`uVBq!ia0vp^{2-A-dE?mA3WGZ;NIEGmGCnrd-E@}MF!}I^*(GFIh7feeU e6jxP>OyFQR6T`&5qIsP=NS~*xpUXO@geCyyAVsAB literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_4.png b/src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_4.png new file mode 100644 index 0000000000000000000000000000000000000000..628a4852f3287a83651b881bf463f7b6690609a7 GIT binary patch literal 369 zcmeAS@N?(olHy`uVBq!ia0vp^{2-A-dE?mA3WXgKFIEGmGCnrd-eqsDCDe=#EA@?MvwiV9; b9h4XtV$LwJU(dS*3Q7h~S3j3^P6=Q#= literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_5.png b/src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_5.png new file mode 100644 index 0000000000000000000000000000000000000000..c0e9894b9ddea5b3b62c265750b6fbe667c16344 GIT binary patch literal 382 zcmeAS@N?(olHy`uVBq!ia0vp^{2-A-dE?mA3WNLZ3IEGmGCnrd-E>8H+^q+_4|HY#ntUfQ8 omN0ag7%#G(J+ZM-aArR+Ok;dmSW2%p+JQ{)boFyt=akR{0M9!~JOBUy literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_6.png b/src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_6.png new file mode 100644 index 0000000000000000000000000000000000000000..ade3e1393c48a9ea484f14c4efcb411514d3008b GIT binary patch literal 373 zcmeAS@N?(olHy`uVBq!ia0vp^{2-A-dE?mA3WGZ^PIEGmGCnrd-E=~{$5I0!FZ2$y+(i494 d>mBQG)ny1+!Nj!0XVO!UMo(8imvv4FO#t6sL}LH| literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_7.png b/src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_7.png new file mode 100644 index 0000000000000000000000000000000000000000..f2f27b633adfd16545a42dc218c9e68f5e85a868 GIT binary patch literal 378 zcmeAS@N?(olHy`uVBq!ia0vp^{2-A-dE?mA3WU6_(IEGmGCnrd-E>8H-_@9U8|I7=lo{S=y kX)fXi*#8+D{BeKA%rIpm3zPoA#43<(Pgg&ebxsLQ0FH@AqyPW_ literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_full.png b/src/main/resources/assets/lemclienthelper/textures/hud/damage_indicator_full.png new file mode 100644 index 0000000000000000000000000000000000000000..c36420e493e9502b89dd48fd3cb058e19d00deae GIT binary patch literal 399 zcmeAS@N?(olHy`uVBq!ia0vp^{2x?)Zs(2%GOayb978PplmDDQ@L@h9r-6}y!J_VmBF6<3 zg#M%_{5apD=fSnW!#Fh|<5%SalVG;Cw2b5@B5QWCw_7l9u}Cnx^|UpBjP!K%b6Mw< G&;$S==}wyf literal 0 HcmV?d00001 diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 0b30aef..6357a50 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -10,7 +10,8 @@ "contributors": [ "Virusnest", "S_N00B", - "DBTDerpbox" + "DBTDerpbox", + "Awsome_Creeper9" ], "contact": { "homepage": "https://github.com/Legacy-Edition-Minigames/lemclienthelper", diff --git a/src/main/resources/lemclienthelper.mixins.json b/src/main/resources/lemclienthelper.mixins.json index 51e5dae..00ec891 100644 --- a/src/main/resources/lemclienthelper.mixins.json +++ b/src/main/resources/lemclienthelper.mixins.json @@ -15,7 +15,8 @@ "SmallInv.invs.MultipleScreenMixin", "SpectateSquaker.MinecraftClientMixin", "SyncedKeybinds.GameOptionsMixin", - "TakeEverything.ScreenHandlerMixin" + "TakeEverything.ScreenHandlerMixin", + "DamageIndicator.DamageAngleMixin" ], "injectors": { "defaultRequire": 1 From 6e932a6d0c827432719219f2ccb4fea4112ef886 Mon Sep 17 00:00:00 2001 From: Awsome-Creeper9 Date: Wed, 1 Jul 2026 12:41:33 -0500 Subject: [PATCH 2/3] Made it so nondirectional damage displays all 8 angle indicators --- .../lemclienthelper/hud/HudMod.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/hud/HudMod.java b/src/main/java/net/kyrptonaught/lemclienthelper/hud/HudMod.java index 19527a6..bb9f8c3 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/hud/HudMod.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/hud/HudMod.java @@ -5,6 +5,7 @@ import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; import net.kyrptonaught.lemclienthelper.LEMClientHelperMod; +import net.minecraft.client.MinecraftClient; import net.minecraft.util.Identifier; import java.util.Arrays; @@ -18,7 +19,6 @@ public class HudMod { public static float DMG_ANGLE = 0; public static int[] DMG_TIME_ANGLE = {100, 100, 100, 100, 100, 100, 100, 100}; - public static void onInitialize() { LEMClientHelperMod.configManager.registerFile(MOD_ID, new HudConfig()); LEMClientHelperMod.configManager.load(MOD_ID); @@ -38,6 +38,25 @@ public static void onInitialize() { } public static void onClientTick() { + MinecraftClient client = MinecraftClient.getInstance(); + if (client.player != null) { + // new dmg taken + if (client.player.hurtTime == 9) { + //check if it's a directional damage before resetting all angles + boolean reset = true; + int[] times = getDMGTimeAngle(); + for (int i = 0; i < times.length; i++) { + if (times[i] == 0) { + reset = false; + break; + } + } + if (reset) { + resetAllTimes(); + } + } + } + for (int i = 0; i < DMG_TIME_ANGLE.length; i++) { if (DMG_TIME_ANGLE[i] < getConfig().damageIndicatorFadeOut) { DMG_TIME_ANGLE[i]++; @@ -94,6 +113,12 @@ else if (Math.abs(angle) <= 180.0 - (45.0/2.0)) { } } + public static void resetAllTimes() { + for (int i = 0; i < DMG_TIME_ANGLE.length; i++) { + DMG_TIME_ANGLE[i] = 0; + } + } + public static int[] getDMGTimeAngle() { return Arrays.copyOf(DMG_TIME_ANGLE, DMG_TIME_ANGLE.length); } From 54d7d8a84702e81cbe98e8c25398838aebcef07d Mon Sep 17 00:00:00 2001 From: Awsome-Creeper9 Date: Sun, 5 Jul 2026 06:49:00 -0500 Subject: [PATCH 3/3] Removed some unused code and made angle calculation more intuitive. --- .../kyrptonaught/lemclienthelper/hud/HudMod.java | 15 +++------------ .../mixin/DamageIndicator/DamageAngleMixin.java | 4 +--- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/hud/HudMod.java b/src/main/java/net/kyrptonaught/lemclienthelper/hud/HudMod.java index bb9f8c3..840662e 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/hud/HudMod.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/hud/HudMod.java @@ -16,7 +16,6 @@ public class HudMod { private static final Identifier ARMOR_HUD_DISABLE = new Identifier("armorhud", "armor_hud_render_disable"); public static boolean SHOULD_RENDER_ARMOR = false; - public static float DMG_ANGLE = 0; public static int[] DMG_TIME_ANGLE = {100, 100, 100, 100, 100, 100, 100, 100}; public static void onInitialize() { @@ -72,20 +71,12 @@ public static boolean shouldDisplayDmgIndicator() { return getConfig().enableDamageIndicator; } - public static float getDMGAngle() { - return DMG_ANGLE; - } - - public static void setDMGAngle(float angle) { - DMG_ANGLE = angle; - } - public static void resetTimeForAngle(float angle) { if (Math.abs(angle) <= (45.0/2.0)) { DMG_TIME_ANGLE[1] = 0; } else if (Math.abs(angle) <= 45.0 + (45.0/2.0)) { - if (angle < 0) { + if (angle > 0) { DMG_TIME_ANGLE[2] = 0; } else { @@ -93,7 +84,7 @@ else if (Math.abs(angle) <= 45.0 + (45.0/2.0)) { } } else if (Math.abs(angle) <= 90.0 + (45.0/2.0)) { - if (angle < 0) { + if (angle > 0) { DMG_TIME_ANGLE[4] = 0; } else { @@ -101,7 +92,7 @@ else if (Math.abs(angle) <= 90.0 + (45.0/2.0)) { } } else if (Math.abs(angle) <= 180.0 - (45.0/2.0)) { - if (angle < 0) { + if (angle > 0) { DMG_TIME_ANGLE[7] = 0; } else { diff --git a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/DamageIndicator/DamageAngleMixin.java b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/DamageIndicator/DamageAngleMixin.java index 1265c1f..96c7f1d 100644 --- a/src/main/java/net/kyrptonaught/lemclienthelper/mixin/DamageIndicator/DamageAngleMixin.java +++ b/src/main/java/net/kyrptonaught/lemclienthelper/mixin/DamageIndicator/DamageAngleMixin.java @@ -16,9 +16,7 @@ private void onAnimateDamage(float yaw, CallbackInfo ci) { // Ensure this logic only runs for the local player on the client if ((Object)this instanceof ClientPlayerEntity player) { // Fix MC related stupidity: - float angle = MathHelper.wrapDegrees(-yaw + 90); - - HudMod.setDMGAngle(angle); + float angle = MathHelper.wrapDegrees(yaw - 90); HudMod.resetTimeForAngle(angle); } }