From 7168372bdc57915e9a398798542504c7eaef99e0 Mon Sep 17 00:00:00 2001 From: enjarai Date: Thu, 28 Mar 2024 23:02:23 +0100 Subject: [PATCH] This is a forge moment ngl --- CHANGELOG.md | 4 +- .../mixin/forge/InGameHudMixin.java | 38 +++++++++++++++++++ .../do_a_barrel_roll.forge.mixins.json | 3 +- gradle.properties | 2 +- 4 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 forge/src/main/java/nl/enjarai/doabarrelroll/mixin/forge/InGameHudMixin.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 4acc8991..edc724da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1 @@ -- Unembedded a dependency on my shared library. - - This reduces disk space required when using more than one of my mods. - - It also makes it easier for me to push fixes to that library without creating updates for every single mod that uses it. \ No newline at end of file +- Fixed an issue with hud rendering on Forge introduced in a recent update. (#127) diff --git a/forge/src/main/java/nl/enjarai/doabarrelroll/mixin/forge/InGameHudMixin.java b/forge/src/main/java/nl/enjarai/doabarrelroll/mixin/forge/InGameHudMixin.java new file mode 100644 index 00000000..8e2b3c17 --- /dev/null +++ b/forge/src/main/java/nl/enjarai/doabarrelroll/mixin/forge/InGameHudMixin.java @@ -0,0 +1,38 @@ +package nl.enjarai.doabarrelroll.mixin.forge; + +import com.llamalad7.mixinextras.sugar.Share; +import com.llamalad7.mixinextras.sugar.ref.LocalFloatRef; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.hud.InGameHud; +import nl.enjarai.doabarrelroll.EventCallbacksClient; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(InGameHud.class) +public abstract class InGameHudMixin { + @Shadow + protected int scaledWidth; + @Shadow + protected int scaledHeight; + + @Inject( + method = "renderCrosshair", + at = @At(value = "HEAD") + ) + private void doABarrelRoll$renderCrosshairHead(DrawContext context, CallbackInfo ci) { + context.getMatrices().push(); + // There's really no way for me to get it, so no tickdelta for you Forge! + EventCallbacksClient.onRenderCrosshair(context, 0, scaledWidth, scaledHeight); + } + + @Inject( + method = "renderCrosshair", + at = @At(value = "RETURN") + ) + private void doABarrelRoll$renderCrosshairReturn(DrawContext context, CallbackInfo ci) { + context.getMatrices().pop(); + } +} diff --git a/forge/src/main/resources/do_a_barrel_roll.forge.mixins.json b/forge/src/main/resources/do_a_barrel_roll.forge.mixins.json index 408e7947..f39ca0da 100644 --- a/forge/src/main/resources/do_a_barrel_roll.forge.mixins.json +++ b/forge/src/main/resources/do_a_barrel_roll.forge.mixins.json @@ -1,12 +1,13 @@ { "required": true, "minVersion": "0.8", - "package": "nl.enjarai.doabarrelroll.mixin", + "package": "nl.enjarai.doabarrelroll.mixin.forge", "refmap": "${mod_id}.refmap.json", "compatibilityLevel": "JAVA_17", "mixins": [ ], "client": [ + "InGameHudMixin" ], "server": [ ], diff --git a/gradle.properties b/gradle.properties index 4a8b4c46..990d92e3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false # Project -mod_version=3.5.3 +mod_version=3.5.4 group=nl.enjarai # Common