diff --git a/build.gradle b/build.gradle index 2808196..65b5036 100644 --- a/build.gradle +++ b/build.gradle @@ -70,7 +70,7 @@ dependencies { // 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" + //modApi "maven.modrinth:immediatelyfast:${project.immediatelyfast_version}+1.21.3-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" } diff --git a/gradle.properties b/gradle.properties index 77569f6..6ae39c5 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.21 -yarn_mappings=1.21+build.2 +minecraft_version=1.21.2 +yarn_mappings=1.21.2+build.1 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.100.1 -yacl_version=3.5.0 -modmenu_version=11.0.0 -immediatelyfast_version=1.2.18 -dabr_version=3.6.1 +fapi_version=0.106.1 +yacl_version=3.6.0 +modmenu_version=12.0.0-beta.1 +immediatelyfast_version=1.3.0 +dabr_version=3.8.0 # Publish Properties -publish_target_min=1.21 -publish_target_max=1.21.1 +publish_target_min=1.21.2 +publish_target_max=1.21.3 mod_modrinth=CWqLEOPt mod_curseforge=972881 mod_github=Octol1ttle/FlightAssistant -git_branch=1.21/dev +git_branch=1.21.2/dev diff --git a/src/main/java/ru/octol1ttle/flightassistant/DrawHelper.java b/src/main/java/ru/octol1ttle/flightassistant/DrawHelper.java index 87ca8f6..4c3e673 100644 --- a/src/main/java/ru/octol1ttle/flightassistant/DrawHelper.java +++ b/src/main/java/ru/octol1ttle/flightassistant/DrawHelper.java @@ -6,7 +6,6 @@ import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.math.Vec3d; -import ru.octol1ttle.flightassistant.compatibility.immediatelyfast.HUDBatching; import ru.octol1ttle.flightassistant.util.ScreenSpaceRendering; public abstract class DrawHelper { @@ -61,14 +60,15 @@ public static void drawMiddleAlignedText(TextRenderer textRenderer, DrawContext } public static int drawHighlightedText(TextRenderer textRenderer, DrawContext context, Text text, int x, int y, Color color, boolean highlight) { - HUDBatching.tryEnd(); if (highlight) { DrawHelper.fill(context, x - 2, y - 1, x + textRenderer.getWidth(text) + 1, y + 8, color); + context.getMatrices().translate(0, 0, 100); DrawHelper.drawText(textRenderer, context, text, x, y, getContrasting(color)); + context.getMatrices().translate(0, 0, -100); } else { DrawHelper.drawText(textRenderer, context, text, x, y, color); } - HUDBatching.tryBegin(); + return SINGLE_LINE_DRAWN; } diff --git a/src/main/java/ru/octol1ttle/flightassistant/FACallbackListener.java b/src/main/java/ru/octol1ttle/flightassistant/FACallbackListener.java index e5a9f89..20a32de 100644 --- a/src/main/java/ru/octol1ttle/flightassistant/FACallbackListener.java +++ b/src/main/java/ru/octol1ttle/flightassistant/FACallbackListener.java @@ -22,9 +22,9 @@ import net.minecraft.entity.projectile.FireworkRocketEntity; import net.minecraft.item.FireworkRocketItem; import net.minecraft.item.ItemStack; +import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.Pair; -import net.minecraft.util.TypedActionResult; import net.minecraft.util.math.Direction; import net.minecraft.util.math.RotationAxis; import net.minecraft.world.World; @@ -137,7 +137,7 @@ public Optional onPitchChange(Entity entity, float pitchDelta) { } @Override - public TypedActionResult interact(PlayerEntity player, World world, Hand hand) { + public ActionResult interact(PlayerEntity player, World world, Hand hand) { ItemStack stack = player.getStackInHand(hand); AirDataComputer data = ComputerRegistry.resolve(AirDataComputer.class); GroundProximityComputer gpws = ComputerRegistry.resolve(GroundProximityComputer.class); @@ -145,10 +145,10 @@ public TypedActionResult interact(PlayerEntity player, World world, H TimeComputer time = ComputerRegistry.resolve(TimeComputer.class); if (!world.isClient() || ComputerRegistry.isFaulted(FireworkController.class)) { - return TypedActionResult.pass(stack); + return ActionResult.PASS; } if (!data.isFlying() || !(stack.getItem() instanceof FireworkRocketItem)) { - return TypedActionResult.pass(stack); + return ActionResult.PASS; } boolean gpwsLocksFireworks = FAConfig.computer().lockFireworksFacingTerrain; @@ -157,7 +157,7 @@ public TypedActionResult interact(PlayerEntity player, World world, H boolean unsafeFireworks = FAConfig.computer().lockUnsafeFireworks && !firework.isFireworkSafe(player.getStackInHand(hand)); if (!firework.activationInProgress && (unsafeFireworks || gpwsDanger)) { - return TypedActionResult.fail(stack); + return ActionResult.FAIL; } if (firework.fireworkResponded) { @@ -168,7 +168,7 @@ public TypedActionResult interact(PlayerEntity player, World world, H firework.fireworkResponded = false; } - return TypedActionResult.pass(stack); + return ActionResult.PASS; } @Override diff --git a/src/main/java/ru/octol1ttle/flightassistant/FAModMenuImpl.java b/src/main/java/ru/octol1ttle/flightassistant/FAModMenuImpl.java index 53363b4..6c88927 100644 --- a/src/main/java/ru/octol1ttle/flightassistant/FAModMenuImpl.java +++ b/src/main/java/ru/octol1ttle/flightassistant/FAModMenuImpl.java @@ -46,16 +46,6 @@ private ConfigCategory hud(Text name, HUDConfig config, HUDConfig defaults) { return ConfigCategory.createBuilder() .name(name) - .option(Option.createBuilder() - .name(Text.translatable("config.flightassistant.hud.batching")) - .available(FlightAssistant.canUseBatching()) - .binding(defaults.batchedRendering, () -> FlightAssistant.canUseBatching() - ? config.batchedRendering - : HUDConfig.BatchedRendering.NO_BATCHING - , o -> config.batchedRendering = o) - .controller(opt -> EnumControllerBuilder.create(opt).enumClass(HUDConfig.BatchedRendering.class)) - .build() - ) .option(Option.createBuilder() .name(Text.translatable("config.flightassistant.hud.scale")) .binding(defaults.hudScale, () -> config.hudScale, o -> config.hudScale = o) diff --git a/src/main/java/ru/octol1ttle/flightassistant/FlightAssistant.java b/src/main/java/ru/octol1ttle/flightassistant/FlightAssistant.java index cb28b8d..1b0ded5 100644 --- a/src/main/java/ru/octol1ttle/flightassistant/FlightAssistant.java +++ b/src/main/java/ru/octol1ttle/flightassistant/FlightAssistant.java @@ -1,14 +1,12 @@ package ru.octol1ttle.flightassistant; import net.fabricmc.api.ClientModInitializer; -import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.MinecraftClient; import net.minecraft.util.Identifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import ru.octol1ttle.flightassistant.computers.ComputerHost; import ru.octol1ttle.flightassistant.config.FAConfig; -import ru.octol1ttle.flightassistant.config.HUDConfig; import ru.octol1ttle.flightassistant.hud.HudDisplayHost; public class FlightAssistant implements ClientModInitializer { @@ -54,12 +52,4 @@ public static ComputerHost getComputerHost() { public static Identifier id(String path) { return Identifier.of(FlightAssistant.MODID, path); } - - public static boolean isHUDBatched() { - return canUseBatching() && FAConfig.hud().batchedRendering != HUDConfig.BatchedRendering.NO_BATCHING; - } - - public static boolean canUseBatching() { - return FabricLoader.getInstance().isModLoaded("immediatelyfast"); - } } diff --git a/src/main/java/ru/octol1ttle/flightassistant/compatibility/immediatelyfast/HUDBatching.java b/src/main/java/ru/octol1ttle/flightassistant/compatibility/immediatelyfast/HUDBatching.java deleted file mode 100644 index c89a040..0000000 --- a/src/main/java/ru/octol1ttle/flightassistant/compatibility/immediatelyfast/HUDBatching.java +++ /dev/null @@ -1,29 +0,0 @@ -package ru.octol1ttle.flightassistant.compatibility.immediatelyfast; - -import ru.octol1ttle.flightassistant.FlightAssistant; - -public class HUDBatching { - public static void tryBegin() { - if (FlightAssistant.isHUDBatched()) { - ImmediatelyFastInterface.beginDirect(); - } - } - - public static void tryBeginIf(boolean condition) { - if (condition) { - tryBegin(); - } - } - - public static void tryEnd() { - if (FlightAssistant.isHUDBatched()) { - ImmediatelyFastInterface.endDirect(); - } - } - - public static void tryEndIf(boolean condition) { - if (condition) { - tryEnd(); - } - } -} diff --git a/src/main/java/ru/octol1ttle/flightassistant/compatibility/immediatelyfast/ImmediatelyFastInterface.java b/src/main/java/ru/octol1ttle/flightassistant/compatibility/immediatelyfast/ImmediatelyFastInterface.java deleted file mode 100644 index 5adb5fe..0000000 --- a/src/main/java/ru/octol1ttle/flightassistant/compatibility/immediatelyfast/ImmediatelyFastInterface.java +++ /dev/null @@ -1,15 +0,0 @@ -package ru.octol1ttle.flightassistant.compatibility.immediatelyfast; - -import net.raphimc.immediatelyfastapi.ImmediatelyFastApi; -import org.jetbrains.annotations.ApiStatus; - -@ApiStatus.Internal -public class ImmediatelyFastInterface { - public static void beginDirect() { - ImmediatelyFastApi.getApiImpl().getBatching().beginHudBatching(); - } - - public static void endDirect() { - ImmediatelyFastApi.getApiImpl().getBatching().endHudBatching(); - } -} 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 6bfae11..2ce4248 100644 --- a/src/main/java/ru/octol1ttle/flightassistant/computers/impl/AirDataComputer.java +++ b/src/main/java/ru/octol1ttle/flightassistant/computers/impl/AirDataComputer.java @@ -26,6 +26,7 @@ import ru.octol1ttle.flightassistant.config.ComputerConfig; import ru.octol1ttle.flightassistant.config.FAConfig; import ru.octol1ttle.flightassistant.config.IndicatorConfig; +import ru.octol1ttle.flightassistant.mixin.EntityInvoker; import ru.octol1ttle.flightassistant.util.events.RollMatrixCallback; import static net.minecraft.SharedConstants.TICKS_PER_SECOND; @@ -76,7 +77,7 @@ public boolean isInvulnerableTo(DamageSource source) { if (!FAConfig.computer().considerInvulnerability) { return false; } - return player().isInvulnerableTo(source) + return ((EntityInvoker) player()).invokeIsAlwaysInvulnerableTo(source) || player().getAbilities().invulnerable && !source.isIn(DamageTypeTags.BYPASSES_INVULNERABILITY) || player().getAbilities().allowFlying && source.isIn(DamageTypeTags.IS_FALL); } @@ -167,7 +168,7 @@ public static float toHeading(float yawDegrees) { } public boolean isFlying() { - return player().isFallFlying(); + return player().isGliding(); } public Vec3d position() { diff --git a/src/main/java/ru/octol1ttle/flightassistant/computers/impl/navigation/FlightPlanner.java b/src/main/java/ru/octol1ttle/flightassistant/computers/impl/navigation/FlightPlanner.java index ec61db2..696e097 100644 --- a/src/main/java/ru/octol1ttle/flightassistant/computers/impl/navigation/FlightPlanner.java +++ b/src/main/java/ru/octol1ttle/flightassistant/computers/impl/navigation/FlightPlanner.java @@ -69,7 +69,7 @@ public void tick() { } private boolean tickLanding(Vector2d target) { - Vec3d landPos = data.findGround(new Vec3d(target.x, data.world().getTopY(), target.y)); + Vec3d landPos = data.findGround(new Vec3d(target.x, data.world().getTopYInclusive(), target.y)); if (landPos == null) { return false; } diff --git a/src/main/java/ru/octol1ttle/flightassistant/computers/impl/safety/AlertController.java b/src/main/java/ru/octol1ttle/flightassistant/computers/impl/safety/AlertController.java index 8548d9e..36e42fe 100644 --- a/src/main/java/ru/octol1ttle/flightassistant/computers/impl/safety/AlertController.java +++ b/src/main/java/ru/octol1ttle/flightassistant/computers/impl/safety/AlertController.java @@ -87,7 +87,7 @@ public void tick() { boolean soundChanged = false; if (alert.soundInstance != null) { - soundChanged = data.sound() == null || !data.sound().getId().equals(alert.soundInstance.getId()); + soundChanged = data.sound() == null || !data.sound().id().equals(alert.soundInstance.getId()); if (soundChanged || interrupt || alert.hidden) { manager.stop(alert.soundInstance); alert.soundInstance = null; diff --git a/src/main/java/ru/octol1ttle/flightassistant/computers/impl/safety/GroundProximityComputer.java b/src/main/java/ru/octol1ttle/flightassistant/computers/impl/safety/GroundProximityComputer.java index bbd4f3e..d8a1193 100644 --- a/src/main/java/ru/octol1ttle/flightassistant/computers/impl/safety/GroundProximityComputer.java +++ b/src/main/java/ru/octol1ttle/flightassistant/computers/impl/safety/GroundProximityComputer.java @@ -164,7 +164,7 @@ private boolean positiveLessOrEquals(float time, float lessOrEquals) { } private BlockPos findHighest(BlockPos.Mutable at) { - while (at.getY() < data.world().getTopY()) { + while (at.getY() < data.world().getTopYInclusive()) { if (!data.isGround(at.move(Direction.UP))) { return at; } diff --git a/src/main/java/ru/octol1ttle/flightassistant/config/FAConfig.java b/src/main/java/ru/octol1ttle/flightassistant/config/FAConfig.java index d14efb5..6bd1920 100644 --- a/src/main/java/ru/octol1ttle/flightassistant/config/FAConfig.java +++ b/src/main/java/ru/octol1ttle/flightassistant/config/FAConfig.java @@ -61,7 +61,7 @@ public static IndicatorConfig indicator() { throw new IllegalStateException("Attempted to retrieve indicator settings when there is no player"); } - if (client.player.isFallFlying()) { + if (client.player.isGliding()) { return INDICATORS_STORAGE_HANDLER.instance().flying; } diff --git a/src/main/java/ru/octol1ttle/flightassistant/config/HUDConfig.java b/src/main/java/ru/octol1ttle/flightassistant/config/HUDConfig.java index bed65f6..907f921 100644 --- a/src/main/java/ru/octol1ttle/flightassistant/config/HUDConfig.java +++ b/src/main/java/ru/octol1ttle/flightassistant/config/HUDConfig.java @@ -1,28 +1,12 @@ package ru.octol1ttle.flightassistant.config; -import dev.isxander.yacl3.api.NameableEnum; import dev.isxander.yacl3.config.v2.api.SerialEntry; -import java.util.Locale; -import net.minecraft.text.Text; public class HUDConfig { - @SerialEntry - public BatchedRendering batchedRendering = BatchedRendering.SINGLE_BATCH; @SerialEntry public float hudScale = 1.0f; @SerialEntry public float frameWidth = 0.6f; @SerialEntry public float frameHeight = 0.6f; - - public enum BatchedRendering implements NameableEnum { - NO_BATCHING, - PER_COMPONENT, - SINGLE_BATCH; - - @Override - public Text getDisplayName() { - return Text.translatable("config.flightassistant.hud.batching." + name().toLowerCase(Locale.ROOT)); - } - } } diff --git a/src/main/java/ru/octol1ttle/flightassistant/hud/HudDisplayHost.java b/src/main/java/ru/octol1ttle/flightassistant/hud/HudDisplayHost.java index 4b50506..eb6c977 100644 --- a/src/main/java/ru/octol1ttle/flightassistant/hud/HudDisplayHost.java +++ b/src/main/java/ru/octol1ttle/flightassistant/hud/HudDisplayHost.java @@ -5,10 +5,7 @@ import net.minecraft.client.gui.DrawContext; import net.minecraft.util.Identifier; import ru.octol1ttle.flightassistant.Dimensions; -import ru.octol1ttle.flightassistant.FlightAssistant; -import ru.octol1ttle.flightassistant.compatibility.immediatelyfast.HUDBatching; import ru.octol1ttle.flightassistant.config.FAConfig; -import ru.octol1ttle.flightassistant.config.HUDConfig; import ru.octol1ttle.flightassistant.hud.api.IHudDisplay; import ru.octol1ttle.flightassistant.hud.impl.AlertDisplay; import ru.octol1ttle.flightassistant.hud.impl.AltitudeDisplay; @@ -57,17 +54,13 @@ public void render(MinecraftClient mc, DrawContext context, float tickDelta) { dim.update(context, renderer.invokeGetFov(mc.gameRenderer.getCamera(), tickDelta, true)); float hudScale = FAConfig.hud().hudScale; - boolean batchAll = FlightAssistant.canUseBatching() && FAConfig.hud().batchedRendering == HUDConfig.BatchedRendering.SINGLE_BATCH; context.getMatrices().push(); context.getMatrices().scale(hudScale, hudScale, hudScale); - HUDBatching.tryBeginIf(batchAll); for (Map.Entry entry : HudDisplayRegistry.getDisplays()) { Identifier id = entry.getKey(); IHudDisplay display = entry.getValue(); - boolean perComponent = FlightAssistant.canUseBatching() && FAConfig.hud().batchedRendering == HUDConfig.BatchedRendering.PER_COMPONENT; - HUDBatching.tryBeginIf(perComponent); try { if (!HudDisplayRegistry.isFaulted(id)) { display.render(context, mc.textRenderer); @@ -77,10 +70,8 @@ public void render(MinecraftClient mc, DrawContext context, float tickDelta) { } catch (Throwable t) { HudDisplayRegistry.markFaulted(id, t, "Exception rendering display with ID: %s".formatted(id)); } - HUDBatching.tryEndIf(perComponent); } - HUDBatching.tryEndIf(batchAll); context.getMatrices().pop(); } } diff --git a/src/main/java/ru/octol1ttle/flightassistant/mixin/EntityInvoker.java b/src/main/java/ru/octol1ttle/flightassistant/mixin/EntityInvoker.java new file mode 100644 index 0000000..73dac75 --- /dev/null +++ b/src/main/java/ru/octol1ttle/flightassistant/mixin/EntityInvoker.java @@ -0,0 +1,12 @@ +package ru.octol1ttle.flightassistant.mixin; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.damage.DamageSource; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(Entity.class) +public interface EntityInvoker { + @Invoker + boolean invokeIsAlwaysInvulnerableTo(DamageSource damageSource); +} diff --git a/src/main/java/ru/octol1ttle/flightassistant/mixin/GameRendererInvoker.java b/src/main/java/ru/octol1ttle/flightassistant/mixin/GameRendererInvoker.java index aa78673..b34287d 100644 --- a/src/main/java/ru/octol1ttle/flightassistant/mixin/GameRendererInvoker.java +++ b/src/main/java/ru/octol1ttle/flightassistant/mixin/GameRendererInvoker.java @@ -8,5 +8,5 @@ @Mixin(GameRenderer.class) public interface GameRendererInvoker { @Invoker - double invokeGetFov(Camera camera, float tickDelta, boolean changingFov); + float invokeGetFov(Camera camera, float tickDelta, boolean changingFov); } diff --git a/src/main/java/ru/octol1ttle/flightassistant/mixin/GameRendererMixin.java b/src/main/java/ru/octol1ttle/flightassistant/mixin/GameRendererMixin.java index 375a533..3c87666 100644 --- a/src/main/java/ru/octol1ttle/flightassistant/mixin/GameRendererMixin.java +++ b/src/main/java/ru/octol1ttle/flightassistant/mixin/GameRendererMixin.java @@ -21,7 +21,7 @@ public class GameRendererMixin { remap = false ) ) - public void updateRoll(RenderTickCounter tickCounter, CallbackInfo ci, @Local(ordinal = 1) Matrix4f matrix4f2) { - RollMatrixCallback.EVENT.invoker().onMatrixUpdate(matrix4f2); + public void updateRoll(RenderTickCounter tickCounter, CallbackInfo ci, @Local(ordinal = 2) Matrix4f matrix4f3) { + RollMatrixCallback.EVENT.invoker().onMatrixUpdate(matrix4f3); } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 6dff783..6726094 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.21", + "minecraft": ">=1.21.2 <1.22", "java": ">=21", "yet_another_config_lib_v3": "*" }, diff --git a/src/main/resources/flightassistant.mixins.json b/src/main/resources/flightassistant.mixins.json index 34bd1dc..7a8ddd2 100644 --- a/src/main/resources/flightassistant.mixins.json +++ b/src/main/resources/flightassistant.mixins.json @@ -4,6 +4,7 @@ "compatibilityLevel": "JAVA_21", "mixins": [], "client": [ + "EntityInvoker", "EntityMixin", "FireworkRocketEntityMixin", "GameRendererInvoker",