From f55ded825f15e2a651d0b197a132d53160b6d401 Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Tue, 20 Aug 2024 13:36:25 +0500 Subject: [PATCH] update: 1.21 --- build.gradle | 4 +-- gradle.properties | 20 +++++++------- .../flightassistant/FACallbackListener.java | 2 +- .../flightassistant/FlightAssistant.java | 2 +- .../mixin/GameRendererMixin.java | 5 ++-- .../flightassistant/mixin/InGameHudMixin.java | 26 +++++++++++++++++++ .../events/AlternateHudRendererCallback.java | 22 ++++++++++++++++ src/main/resources/fabric.mod.json | 2 +- .../resources/flightassistant.mixins.json | 3 ++- 9 files changed, 68 insertions(+), 18 deletions(-) create mode 100644 src/main/java/ru/octol1ttle/flightassistant/mixin/InGameHudMixin.java create mode 100644 src/main/java/ru/octol1ttle/flightassistant/util/events/AlternateHudRendererCallback.java diff --git a/build.gradle b/build.gradle index 20de8077..28081962 100644 --- a/build.gradle +++ b/build.gradle @@ -62,7 +62,7 @@ dependencies { modImplementation "net.fabricmc:fabric-loader:${project.floader_version}" // Embedded: Alternate HudRendererCallback to fix HUD not rendering behind chat - include(modImplementation "com.github.shadowhunt22:alternate-hudrenderercallback:${project.ahrc_version}") + //include(modImplementation "com.github.shadowhunt22:alternate-hudrenderercallback:${project.ahrc_version}") // Required: Fabric API for callbacks modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fapi_version}+${project.minecraft_version}" // Required: YACL for config storage and screen @@ -72,7 +72,7 @@ dependencies { // Optional: ImmediatelyFast for batching support to increase rendering performance modApi "maven.modrinth:immediatelyfast:${project.immediatelyfast_version}+${project.minecraft_version}-fabric" // Optional: Do a Barrel Roll to control roll via RollController - modApi "nl.enjarai:do-a-barrel-roll:${project.dabr_version}-fabric" + modApi "nl.enjarai:do-a-barrel-roll:${project.dabr_version}+${project.minecraft_version}-fabric" } processResources { diff --git a/gradle.properties b/gradle.properties index 40741f0a..77569f65 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,8 +4,8 @@ org.gradle.parallel=true # Fabric Properties # check these on https://fabricmc.net/develop -minecraft_version=1.20.5 -yarn_mappings=1.20.5+build.1 +minecraft_version=1.21 +yarn_mappings=1.21+build.2 floader_version=0.15.10 # Mod Properties @@ -15,15 +15,15 @@ archives_base_name=flightassistant # Dependencies ahrc_version=1.20.5-1.0.0 -fapi_version=0.97.5 -yacl_version=3.4.0 -modmenu_version=10.0.0-beta.1 -immediatelyfast_version=1.2.12 -dabr_version=3.5.7+1.20.6 +fapi_version=0.100.1 +yacl_version=3.5.0 +modmenu_version=11.0.0 +immediatelyfast_version=1.2.18 +dabr_version=3.6.1 # Publish Properties -publish_target_min=1.20.5 -publish_target_max=1.20.6 +publish_target_min=1.21 +publish_target_max=1.21.1 mod_modrinth=CWqLEOPt mod_curseforge=972881 mod_github=Octol1ttle/FlightAssistant -git_branch=1.20.5/dev +git_branch=1.21/dev diff --git a/src/main/java/ru/octol1ttle/flightassistant/FACallbackListener.java b/src/main/java/ru/octol1ttle/flightassistant/FACallbackListener.java index 515e9b64..e5a9f891 100644 --- a/src/main/java/ru/octol1ttle/flightassistant/FACallbackListener.java +++ b/src/main/java/ru/octol1ttle/flightassistant/FACallbackListener.java @@ -4,7 +4,6 @@ import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.tree.LiteralCommandNode; -import com.shadowhunter22.api.client.renderer.v1.AlternateHudRendererCallback; import java.util.Optional; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; @@ -43,6 +42,7 @@ import ru.octol1ttle.flightassistant.config.FAConfig; import ru.octol1ttle.flightassistant.registries.ComputerRegistry; import ru.octol1ttle.flightassistant.util.ScreenSpaceRendering; +import ru.octol1ttle.flightassistant.util.events.AlternateHudRendererCallback; import ru.octol1ttle.flightassistant.util.events.ChangeLookDirectionEvents; import ru.octol1ttle.flightassistant.util.events.FireworkBoostCallback; diff --git a/src/main/java/ru/octol1ttle/flightassistant/FlightAssistant.java b/src/main/java/ru/octol1ttle/flightassistant/FlightAssistant.java index 5e04eca3..cb28b8da 100644 --- a/src/main/java/ru/octol1ttle/flightassistant/FlightAssistant.java +++ b/src/main/java/ru/octol1ttle/flightassistant/FlightAssistant.java @@ -52,7 +52,7 @@ public static ComputerHost getComputerHost() { } public static Identifier id(String path) { - return new Identifier(FlightAssistant.MODID, path); + return Identifier.of(FlightAssistant.MODID, path); } public static boolean isHUDBatched() { diff --git a/src/main/java/ru/octol1ttle/flightassistant/mixin/GameRendererMixin.java b/src/main/java/ru/octol1ttle/flightassistant/mixin/GameRendererMixin.java index 9ec47787..375a5336 100644 --- a/src/main/java/ru/octol1ttle/flightassistant/mixin/GameRendererMixin.java +++ b/src/main/java/ru/octol1ttle/flightassistant/mixin/GameRendererMixin.java @@ -2,6 +2,7 @@ import com.llamalad7.mixinextras.sugar.Local; import net.minecraft.client.render.GameRenderer; +import net.minecraft.client.render.RenderTickCounter; import org.joml.Matrix4f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -15,12 +16,12 @@ public class GameRendererMixin { method = "renderWorld", at = @At( value = "INVOKE_ASSIGN", - target = "Lorg/joml/Matrix4f;rotationXYZ(FFF)Lorg/joml/Matrix4f;", + target = "Lorg/joml/Matrix4f;rotation(Lorg/joml/Quaternionfc;)Lorg/joml/Matrix4f;", ordinal = 0, remap = false ) ) - public void updateRoll(float tickDelta, long limitTime, CallbackInfo ci, @Local(ordinal = 1) Matrix4f matrix4f2) { + public void updateRoll(RenderTickCounter tickCounter, CallbackInfo ci, @Local(ordinal = 1) Matrix4f matrix4f2) { RollMatrixCallback.EVENT.invoker().onMatrixUpdate(matrix4f2); } } diff --git a/src/main/java/ru/octol1ttle/flightassistant/mixin/InGameHudMixin.java b/src/main/java/ru/octol1ttle/flightassistant/mixin/InGameHudMixin.java new file mode 100644 index 00000000..fc165307 --- /dev/null +++ b/src/main/java/ru/octol1ttle/flightassistant/mixin/InGameHudMixin.java @@ -0,0 +1,26 @@ +package ru.octol1ttle.flightassistant.mixin; + +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.LayeredDrawer; +import net.minecraft.client.gui.hud.InGameHud; +import org.spongepowered.asm.mixin.Final; +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; +import ru.octol1ttle.flightassistant.util.events.AlternateHudRendererCallback; + +@Mixin(InGameHud.class) +public class InGameHudMixin { + @Shadow + @Final + private LayeredDrawer layeredDrawer; + + // modifications made: changed injection point + @Inject(method = "", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/LayeredDrawer;addLayer(Lnet/minecraft/client/gui/LayeredDrawer$Layer;)Lnet/minecraft/client/gui/LayeredDrawer;", ordinal = 3)) + public void render(MinecraftClient client, CallbackInfo ci) { + // modifications made: changed from FAPIs interface to my interface + this.layeredDrawer.addLayer((context, tickCounter) -> AlternateHudRendererCallback.EVENT.invoker().onHudRender(context, tickCounter.getTickDelta(true))); + } +} diff --git a/src/main/java/ru/octol1ttle/flightassistant/util/events/AlternateHudRendererCallback.java b/src/main/java/ru/octol1ttle/flightassistant/util/events/AlternateHudRendererCallback.java new file mode 100644 index 00000000..632c821f --- /dev/null +++ b/src/main/java/ru/octol1ttle/flightassistant/util/events/AlternateHudRendererCallback.java @@ -0,0 +1,22 @@ +package ru.octol1ttle.flightassistant.util.events; + +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; +import net.minecraft.client.gui.DrawContext; + +public interface AlternateHudRendererCallback { + // modifications mode: change HudRendererCallback -> AlternateHudRendererCallback + Event EVENT = EventFactory.createArrayBacked(AlternateHudRendererCallback.class, (listeners) -> (matrixStack, delta) -> { + for (AlternateHudRendererCallback event : listeners) { + event.onHudRender(matrixStack, delta); + } + }); + + /** + * Called after rendering the whole hud, which is displayed in game, in a world. + * + * @param drawContext the {@link DrawContext} instance + * @param tickDelta Progress for linearly interpolating between the previous and current game state + */ + void onHudRender(DrawContext drawContext, float tickDelta); +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index ac700dd2..6dff7830 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -37,7 +37,7 @@ "depends": { "fabricloader": ">=0.15.10", "fabric-api": "*", - "minecraft": ">=1.20.5 <1.21", + "minecraft": "^1.21", "java": ">=21", "yet_another_config_lib_v3": "*" }, diff --git a/src/main/resources/flightassistant.mixins.json b/src/main/resources/flightassistant.mixins.json index 48837504..34bd1dc1 100644 --- a/src/main/resources/flightassistant.mixins.json +++ b/src/main/resources/flightassistant.mixins.json @@ -7,7 +7,8 @@ "EntityMixin", "FireworkRocketEntityMixin", "GameRendererInvoker", - "GameRendererMixin" + "GameRendererMixin", + "InGameHudMixin" ], "injectors": { "defaultRequire": 1