From 205dbc255e99f5b368ead9ef78dcb4041b104f80 Mon Sep 17 00:00:00 2001 From: LostLuma Date: Fri, 29 Sep 2023 03:46:46 +0200 Subject: [PATCH] 1.19.0 --- gradle/libs.versions.toml | 8 +++---- .../java/dynamic_fps/impl/GraphicsState.java | 2 +- .../java/dynamic_fps/impl/PowerState.java | 2 +- .../impl/mixin/ToastComponentMixin.java | 14 +++++++---- .../impl/util/HudInfoRenderer.java | 23 +++++++------------ .../dynamic_fps/impl/util/OptionsHolder.java | 5 ++-- src/main/resources/fabric.mod.json | 4 +--- 7 files changed, 27 insertions(+), 31 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ac0a3c77..5661385c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,11 +1,11 @@ [versions] -minecraft = "1.20" +minecraft = "1.19" fabric_loader = "0.14.22" -modmenu = "7.0.1" -fabric_api = "0.83.0+1.20" +modmenu = "4.0.0" +fabric_api = "0.55.3+1.19" -cloth_config = "11.0.99" +cloth_config = "7.0.72" [libraries] minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" } diff --git a/src/main/java/dynamic_fps/impl/GraphicsState.java b/src/main/java/dynamic_fps/impl/GraphicsState.java index 3f749711..12a7d88a 100644 --- a/src/main/java/dynamic_fps/impl/GraphicsState.java +++ b/src/main/java/dynamic_fps/impl/GraphicsState.java @@ -37,7 +37,7 @@ public DataResult read(DynamicOps ops, T input) { var value = ops.getStringValue(input).get().left(); if (value.isEmpty()) { - return DataResult.error(() -> "Graphics state must not be empty!"); + return DataResult.error("Graphics state must not be empty!"); } else { return DataResult.success(GraphicsState.valueOf(value.get().toUpperCase(Locale.ROOT))); } diff --git a/src/main/java/dynamic_fps/impl/PowerState.java b/src/main/java/dynamic_fps/impl/PowerState.java index 00a6d530..d5d76358 100644 --- a/src/main/java/dynamic_fps/impl/PowerState.java +++ b/src/main/java/dynamic_fps/impl/PowerState.java @@ -51,7 +51,7 @@ public DataResult read(DynamicOps ops, T input) { var value = ops.getStringValue(input).get().left(); if (value.isEmpty()) { - return DataResult.error(() -> "Power state must not be empty!"); + return DataResult.error("Power state must not be empty!"); } else { return DataResult.success(PowerState.valueOf(value.get().toUpperCase(Locale.ROOT))); } diff --git a/src/main/java/dynamic_fps/impl/mixin/ToastComponentMixin.java b/src/main/java/dynamic_fps/impl/mixin/ToastComponentMixin.java index 52368925..03f2694b 100644 --- a/src/main/java/dynamic_fps/impl/mixin/ToastComponentMixin.java +++ b/src/main/java/dynamic_fps/impl/mixin/ToastComponentMixin.java @@ -1,19 +1,23 @@ package dynamic_fps.impl.mixin; +import java.util.Deque; + 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.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.Redirect; import dynamic_fps.impl.DynamicFPSMod; +import net.minecraft.client.gui.components.toasts.Toast; import net.minecraft.client.gui.components.toasts.ToastComponent; @Mixin(ToastComponent.class) public class ToastComponentMixin { - @Inject(method = "freeSlots", at = @At("HEAD"), cancellable = true) - private void hasFreeSlots(CallbackInfoReturnable callbackInfo) { + @Redirect(method = "render", at = @At(value = "INVOKE", target = "Ljava/util/Deque;isEmpty()Z")) + private boolean onQueueIsEmpty(Deque queued) { if (!DynamicFPSMod.shouldShowToasts()) { - callbackInfo.setReturnValue(0); + return true; + } else { + return queued.isEmpty(); } } } diff --git a/src/main/java/dynamic_fps/impl/util/HudInfoRenderer.java b/src/main/java/dynamic_fps/impl/util/HudInfoRenderer.java index 2026a883..cc1333d2 100644 --- a/src/main/java/dynamic_fps/impl/util/HudInfoRenderer.java +++ b/src/main/java/dynamic_fps/impl/util/HudInfoRenderer.java @@ -3,44 +3,37 @@ import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.gui.Font.DisplayMode; import net.minecraft.network.chat.Component; import static dynamic_fps.impl.util.Localization.localized; -import org.joml.Matrix4f; +import com.mojang.blaze3d.vertex.PoseStack; import dynamic_fps.impl.DynamicFPSMod; public final class HudInfoRenderer implements HudRenderCallback { @Override - public void onHudRender(GuiGraphics drawContext, float tickDelta) { + public void onHudRender(PoseStack poseStack, float tickDelta) { if (DynamicFPSMod.isDisabled()) { - drawCenteredText(drawContext, localized("gui", "hud.disabled"), 32); + drawCenteredText(poseStack, localized("gui", "hud.disabled"), 32); } else if (DynamicFPSMod.isForcingLowFPS()) { - drawCenteredText(drawContext, localized("gui", "hud.reducing"), 32); + drawCenteredText(poseStack, localized("gui", "hud.reducing"), 32); } } - private void drawCenteredText(GuiGraphics drawContext, Component component, float y) { + private void drawCenteredText(PoseStack poseStack, Component component, float y) { Minecraft client = Minecraft.getInstance(); Font fontRenderer = client.gui.getFont(); int windowWidth = client.getWindow().getGuiScaledWidth(); int stringWidth = fontRenderer.width(component); - fontRenderer.drawInBatch( + fontRenderer.drawShadow( + poseStack, component, (windowWidth - stringWidth) / 2f, y, - 0xFFFFFFFF, - true, - new Matrix4f(), - drawContext.bufferSource(), - DisplayMode.NORMAL, - 0, - 255 + 0xFFFFFFFF ); } } diff --git a/src/main/java/dynamic_fps/impl/util/OptionsHolder.java b/src/main/java/dynamic_fps/impl/util/OptionsHolder.java index f22862e3..a1f6a319 100644 --- a/src/main/java/dynamic_fps/impl/util/OptionsHolder.java +++ b/src/main/java/dynamic_fps/impl/util/OptionsHolder.java @@ -1,6 +1,7 @@ package dynamic_fps.impl.util; import dynamic_fps.impl.GraphicsState; +import net.minecraft.client.AmbientOcclusionStatus; import net.minecraft.client.CloudStatus; import net.minecraft.client.GraphicsStatus; import net.minecraft.client.Options; @@ -14,7 +15,7 @@ public class OptionsHolder { private static CloudStatus cloudStatus; private static GraphicsStatus graphicsStatus; - private static boolean ambientOcclusion; + private static AmbientOcclusionStatus ambientOcclusion; private static ParticleStatus particlesStatus; private static boolean entityShadows; private static double entityDistance; @@ -52,7 +53,7 @@ public static void applyOptions(Options options, GraphicsState state) { if (state == GraphicsState.MINIMAL) { options.graphicsMode().set(GraphicsStatus.FAST); - options.ambientOcclusion().set(false); + options.ambientOcclusion().set(AmbientOcclusionStatus.OFF); } } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 98698870..fea9044a 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -33,7 +33,7 @@ ], "depends": { - "minecraft": ">=1.20.0", + "minecraft": ["=1.19.0", "=1.19.1", "=1.19.2"], "fabricloader": ">=0.14.22", "fabric-resource-loader-v0": "*", "fabric-rendering-v1": "*", @@ -54,7 +54,6 @@ "net.minecraft.class_426", "net.minecraft.class_4288", "net.minecraft.class_6777", - "net.minecraft.class_443", "net.minecraft.class_446", "net.minecraft.class_445", "net.minecraft.class_6599" @@ -71,7 +70,6 @@ "net.minecraft.class_426": "net.minecraft.client.gui.screens.LanguageSelectScreen", "net.minecraft.class_4288": "net.minecraft.client.gui.screens.MouseSettingsScreen", "net.minecraft.class_6777": "net.minecraft.client.gui.screens.OnlineOptionsScreen", - "net.minecraft.class_443": "net.minecraft.client.gui.screens.SoundOptionsScreen", "net.minecraft.class_446": "net.minecraft.client.gui.screens.VideoSettingsScreen", "net.minecraft.class_445": "net.minecraft.client.gui.screens.WinScreen", "net.minecraft.class_6599": "net.minecraft.client.gui.screens.controls.KeyBindsScreen"