From a2130c73d639e77c4b616adbabf6dab6ff108159 Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Fri, 21 Jun 2024 19:06:32 +0500 Subject: [PATCH] update: 1.20.5 Signed-off-by: Octol1ttle --- .github/workflows/build.yml | 1 - build.gradle | 10 +++---- gradle.properties | 24 ++++++++--------- .../computers/events/RollMatrixCallback.java | 23 ++++++++++++++++ .../computers/impl/AirDataComputer.java | 8 +++--- .../impl/autoflight/FireworkController.java | 12 ++++++--- .../flightassistant/config/FAConfig.java | 2 +- .../mixin/GameRendererMixin.java | 26 +++++++++++++++++++ src/main/resources/fabric.mod.json | 6 ++--- .../resources/flightassistant.mixins.json | 5 ++-- 10 files changed, 85 insertions(+), 32 deletions(-) create mode 100644 src/main/java/ru/octol1ttle/flightassistant/computers/events/RollMatrixCallback.java create mode 100644 src/main/java/ru/octol1ttle/flightassistant/mixin/GameRendererMixin.java diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7d558e5a..1248ca1b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,6 @@ jobs: matrix: # Use these Java versions java: [ - 17, # Current Java LTS & minimum supported by Minecraft 21, # Current Java LTS ] runs-on: ubuntu-22.04 diff --git a/build.gradle b/build.gradle index a350e627..ea61ab70 100644 --- a/build.gradle +++ b/build.gradle @@ -57,13 +57,13 @@ dependencies { // 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 - modImplementation "dev.isxander.yacl:yet-another-config-lib-fabric:${project.yacl_version}+${project.minecraft_version}" + modImplementation "dev.isxander:yet-another-config-lib:${project.yacl_version}+${project.minecraft_version}-fabric" // Optional: Mod Menu to access the YACL config screen modApi "com.terraformersmc:modmenu:${project.modmenu_version}" // 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}+${project.minecraft_version}-fabric" + modApi "nl.enjarai:do-a-barrel-roll:${project.dabr_version}-fabric" } processResources { @@ -80,7 +80,7 @@ yamlang { } tasks.withType(JavaCompile).configureEach { - it.options.release = 17 + it.options.release = 21 } java { @@ -89,8 +89,8 @@ java { // If you remove this line, sources will not be generated. withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } jar { diff --git a/gradle.properties b/gradle.properties index bf3e7548..0ecc294c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,9 +4,9 @@ org.gradle.parallel=true # Fabric Properties # check these on https://fabricmc.net/develop -minecraft_version=1.20.4 -yarn_mappings=1.20.4+build.3 -floader_version=0.15.3 +minecraft_version=1.20.5 +yarn_mappings=1.20.5+build.1 +floader_version=0.15.10 # Mod Properties mod_version=2.3.0 @@ -14,16 +14,16 @@ maven_group=ru.octol1ttle.flightassistant archives_base_name=flightassistant # Dependencies -ahrc_version=1.20.x-0.1.3 -fapi_version=0.96.4 -yacl_version=3.3.1 -modmenu_version=9.0.0 -immediatelyfast_version=1.2.8 -dabr_version=3.3.8 +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 # Publish Properties -publish_target_min=1.20 -publish_target_max=1.20.4 +publish_target_min=1.20.5 +publish_target_max=1.20.6 mod_modrinth=CWqLEOPt mod_curseforge=972881 mod_github=Octol1ttle/FlightAssistant -git_branch=dev +git_branch=1.20.5/dev diff --git a/src/main/java/ru/octol1ttle/flightassistant/computers/events/RollMatrixCallback.java b/src/main/java/ru/octol1ttle/flightassistant/computers/events/RollMatrixCallback.java new file mode 100644 index 00000000..431575a6 --- /dev/null +++ b/src/main/java/ru/octol1ttle/flightassistant/computers/events/RollMatrixCallback.java @@ -0,0 +1,23 @@ +package ru.octol1ttle.flightassistant.computers.events; + +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; +import org.joml.Matrix4f; + +public interface RollMatrixCallback { + Event EVENT = EventFactory.createArrayBacked( + RollMatrixCallback.class, + (listeners) -> (matrix4f) -> { + for (RollMatrixCallback event : listeners) { + event.onMatrixUpdate(matrix4f); + } + } + ); + + /** + * Called after the roll matrix has been updated + * + * @param matrix4f the roll matrix + */ + void onMatrixUpdate(Matrix4f matrix4f); +} \ No newline at end of file diff --git a/src/main/java/ru/octol1ttle/flightassistant/computers/impl/AirDataComputer.java b/src/main/java/ru/octol1ttle/flightassistant/computers/impl/AirDataComputer.java index 6ccc9bca..f7a5dff1 100644 --- a/src/main/java/ru/octol1ttle/flightassistant/computers/impl/AirDataComputer.java +++ b/src/main/java/ru/octol1ttle/flightassistant/computers/impl/AirDataComputer.java @@ -1,7 +1,6 @@ package ru.octol1ttle.flightassistant.computers.impl; import com.google.common.collect.Iterables; -import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.block.BlockState; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; @@ -21,10 +20,11 @@ import net.minecraft.world.World; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.joml.Matrix3f; +import org.joml.Matrix4f; import ru.octol1ttle.flightassistant.DrawHelper; import ru.octol1ttle.flightassistant.FAMathHelper; import ru.octol1ttle.flightassistant.computers.api.ITickableComputer; +import ru.octol1ttle.flightassistant.computers.events.RollMatrixCallback; import ru.octol1ttle.flightassistant.config.ComputerConfig; import ru.octol1ttle.flightassistant.config.FAConfig; import ru.octol1ttle.flightassistant.config.IndicatorConfig; @@ -44,12 +44,12 @@ public class AirDataComputer implements ITickableComputer { public AirDataComputer(MinecraftClient mc) { this.mc = mc; + RollMatrixCallback.EVENT.register(matrix4f -> roll = computeRoll(matrix4f)); } @Override public void tick() { velocity = player().getVelocity().multiply(TICKS_PER_SECOND); - roll = computeRoll(RenderSystem.getInverseViewRotationMatrix().invert()); isCurrentChunkLoaded = isCurrentChunkLoaded(); groundLevel = computeGroundLevel(); flightPitch = computeFlightPitch(velocity, pitch()); @@ -87,7 +87,7 @@ public boolean isInvulnerable() { return player().isInvulnerable() || player().getAbilities().invulnerable; } - private float computeRoll(Matrix3f matrix) { + private float computeRoll(Matrix4f matrix) { return validate(FAMathHelper.toDegrees(Math.atan2(-matrix.m10(), matrix.m11())), -180.0f, 180.0f); } diff --git a/src/main/java/ru/octol1ttle/flightassistant/computers/impl/autoflight/FireworkController.java b/src/main/java/ru/octol1ttle/flightassistant/computers/impl/autoflight/FireworkController.java index a21b4282..323ab933 100644 --- a/src/main/java/ru/octol1ttle/flightassistant/computers/impl/autoflight/FireworkController.java +++ b/src/main/java/ru/octol1ttle/flightassistant/computers/impl/autoflight/FireworkController.java @@ -1,11 +1,11 @@ package ru.octol1ttle.flightassistant.computers.impl.autoflight; import net.minecraft.client.MinecraftClient; +import net.minecraft.component.DataComponentTypes; +import net.minecraft.component.type.FireworksComponent; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.FireworkRocketItem; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.nbt.NbtElement; import net.minecraft.util.Hand; import ru.octol1ttle.flightassistant.computers.api.IThrustHandler; import ru.octol1ttle.flightassistant.computers.api.ITickableComputer; @@ -129,8 +129,12 @@ public boolean isFireworkSafe(ItemStack stack) { if (data.isInvulnerable()) { return true; } - NbtCompound nbtCompound = stack.getSubNbt("Fireworks"); - return nbtCompound == null || nbtCompound.getList("Explosions", NbtElement.COMPOUND_TYPE).isEmpty(); + + FireworksComponent component = stack.getComponents().get(DataComponentTypes.FIREWORKS); + if (component == null) { + throw new AssertionError(); + } + return component.explosions().isEmpty(); } @Override diff --git a/src/main/java/ru/octol1ttle/flightassistant/config/FAConfig.java b/src/main/java/ru/octol1ttle/flightassistant/config/FAConfig.java index abd5df1e..d14efb5b 100644 --- a/src/main/java/ru/octol1ttle/flightassistant/config/FAConfig.java +++ b/src/main/java/ru/octol1ttle/flightassistant/config/FAConfig.java @@ -66,7 +66,7 @@ public static IndicatorConfig indicator() { } if (!client.player.getAbilities().allowFlying) { - for (ItemStack stack : client.player.getItemsEquipped()) { + for (ItemStack stack : client.player.getEquippedItems()) { if (Items.ELYTRA.equals(stack.getItem())) { return INDICATORS_STORAGE_HANDLER.instance().notFlyingHasElytra; } diff --git a/src/main/java/ru/octol1ttle/flightassistant/mixin/GameRendererMixin.java b/src/main/java/ru/octol1ttle/flightassistant/mixin/GameRendererMixin.java new file mode 100644 index 00000000..6dff4dcf --- /dev/null +++ b/src/main/java/ru/octol1ttle/flightassistant/mixin/GameRendererMixin.java @@ -0,0 +1,26 @@ +package ru.octol1ttle.flightassistant.mixin; + +import com.llamalad7.mixinextras.sugar.Local; +import net.minecraft.client.render.GameRenderer; +import org.joml.Matrix4f; +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; +import ru.octol1ttle.flightassistant.computers.events.RollMatrixCallback; + +@Mixin(GameRenderer.class) +public class GameRendererMixin { + @Inject( + method = "renderWorld", + at = @At( + value = "INVOKE_ASSIGN", + target = "Lorg/joml/Matrix4f;rotationXYZ(FFF)Lorg/joml/Matrix4f;", + ordinal = 0, + remap = false + ) + ) + public void updateRoll(float tickDelta, long limitTime, CallbackInfo ci, @Local(ordinal = 1) Matrix4f matrix4f2) { + RollMatrixCallback.EVENT.invoker().onMatrixUpdate(matrix4f2); + } +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 247ce69c..ac700dd2 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -35,10 +35,10 @@ "flightassistant.mixins.json" ], "depends": { - "fabricloader": ">=0.15.3", + "fabricloader": ">=0.15.10", "fabric-api": "*", - "minecraft": ">=1.20.0 <1.20.5", - "java": ">=17", + "minecraft": ">=1.20.5 <1.21", + "java": ">=21", "yet_another_config_lib_v3": "*" }, "recommends": { diff --git a/src/main/resources/flightassistant.mixins.json b/src/main/resources/flightassistant.mixins.json index 5af8a088..48837504 100644 --- a/src/main/resources/flightassistant.mixins.json +++ b/src/main/resources/flightassistant.mixins.json @@ -1,12 +1,13 @@ { "required": true, "package": "ru.octol1ttle.flightassistant.mixin", - "compatibilityLevel": "JAVA_17", + "compatibilityLevel": "JAVA_21", "mixins": [], "client": [ "EntityMixin", "FireworkRocketEntityMixin", - "GameRendererInvoker" + "GameRendererInvoker", + "GameRendererMixin" ], "injectors": { "defaultRequire": 1