diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d6fea4e4..df24f0ab 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,22 +1,22 @@ [versions] -minecraft = "1.20.4" +minecraft = "1.19.3" # Platform libraries fabric_loader = "0.15.6" -fabric_api = "0.96.1+1.20.4" +fabric_api = "0.76.1+1.19.3" -forge = "1.20.4-49.0.30" +forge = "1.19.3-44.1.23" -neoforge = "20.4.160-beta" +# neoforge = "20.4.160-beta" quilt_loader = "0.23.1" -quilt_standard_libraries = "7.0.0-alpha.10+1.20.2" +quilt_standard_libraries = "4.0.0-beta.13+1.19.3" # Third-party libraries -modmenu = "9.0.0" -cloth_config = "13.0.121" +modmenu = "5.1.0" +cloth_config = "9.1.104" mixinextras = "0.3.5" @@ -30,7 +30,7 @@ fabric_loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric_l forge = { module = "net.minecraftforge:forge", version.ref = "forge" } -neoforge = { module = "net.neoforged:neoforge", version.ref = "neoforge" } +# neoforge = { module = "net.neoforged:neoforge", version.ref = "neoforge" } quilt_loader = { module = "org.quiltmc:quilt-loader", version.ref = "quilt_loader" } qsl_lifecycle_events = { module = "org.quiltmc.qsl.core:lifecycle_events", version.ref = "quilt_standard_libraries" } diff --git a/platforms/common/src/main/java/dynamic_fps/impl/compat/ClothConfig.java b/platforms/common/src/main/java/dynamic_fps/impl/compat/ClothConfig.java index 17b5d87d..d2a90c33 100644 --- a/platforms/common/src/main/java/dynamic_fps/impl/compat/ClothConfig.java +++ b/platforms/common/src/main/java/dynamic_fps/impl/compat/ClothConfig.java @@ -10,7 +10,6 @@ import me.shedaniel.clothconfig2.impl.builders.SubCategoryBuilder; import net.minecraft.ChatFormatting; import net.minecraft.client.gui.screens.Screen; -import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; import net.minecraft.sounds.SoundSource; @@ -43,7 +42,7 @@ public static Screen genConfigScreen(Screen parent) { ); general.addEntry( - entryBuilder.startTextDescription(CommonComponents.SPACE).build() + entryBuilder.startTextDescription(Component.literal(" ")).build() ); general.addEntry( diff --git a/platforms/common/src/main/java/dynamic_fps/impl/mixin/GuiMixin.java b/platforms/common/src/main/java/dynamic_fps/impl/mixin/GuiMixin.java index dd877a20..66af3434 100644 --- a/platforms/common/src/main/java/dynamic_fps/impl/mixin/GuiMixin.java +++ b/platforms/common/src/main/java/dynamic_fps/impl/mixin/GuiMixin.java @@ -1,6 +1,5 @@ package dynamic_fps.impl.mixin; -import dynamic_fps.impl.util.HudInfoRenderer; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -8,7 +7,6 @@ import dynamic_fps.impl.DynamicFPSMod; import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiGraphics; @Mixin(Gui.class) public class GuiMixin { @@ -21,18 +19,4 @@ private void shouldRender(CallbackInfo callbackInfo) { callbackInfo.cancel(); } } - - /** - * Render info on whether Dynamic FPS is disabled or always reducing the user's FPS. - */ - @Inject( - method = "render", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/gui/Gui;renderSavingIndicator(Lnet/minecraft/client/gui/GuiGraphics;)V" - ) - ) - private void render(GuiGraphics guiGraphics, float f, CallbackInfo callbackInfo) { - HudInfoRenderer.renderInfo(guiGraphics); - } } diff --git a/platforms/common/src/main/java/dynamic_fps/impl/mixin/ToastComponentMixin.java b/platforms/common/src/main/java/dynamic_fps/impl/mixin/ToastComponentMixin.java index 52368925..03f2694b 100644 --- a/platforms/common/src/main/java/dynamic_fps/impl/mixin/ToastComponentMixin.java +++ b/platforms/common/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/platforms/common/src/main/java/dynamic_fps/impl/util/HudInfoRenderer.java b/platforms/common/src/main/java/dynamic_fps/impl/util/HudInfoRenderer.java index 1114cba3..7ed00452 100644 --- a/platforms/common/src/main/java/dynamic_fps/impl/util/HudInfoRenderer.java +++ b/platforms/common/src/main/java/dynamic_fps/impl/util/HudInfoRenderer.java @@ -2,44 +2,37 @@ 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 { private static final Minecraft minecraft = Minecraft.getInstance(); - public static void renderInfo(GuiGraphics guiGraphics) { + public static void renderInfo(PoseStack poseStack) { if (DynamicFPSMod.disabledByUser()) { - drawCenteredText(guiGraphics, localized("gui", "hud.disabled"), 32); + drawCenteredText(poseStack, localized("gui", "hud.disabled"), 32); } else if (DynamicFPSMod.isForcingLowFPS()) { - drawCenteredText(guiGraphics, localized("gui", "hud.reducing"), 32); + drawCenteredText(poseStack, localized("gui", "hud.reducing"), 32); } } - private static void drawCenteredText(GuiGraphics guiGraphics, Component component, float y) { + private static void drawCenteredText(PoseStack poseStack, Component component, float y) { Font fontRenderer = minecraft.gui.getFont(); int stringWidth = fontRenderer.width(component); int windowWidth = minecraft.getWindow().getGuiScaledWidth(); - fontRenderer.drawInBatch( + fontRenderer.drawShadow( + poseStack, component, (windowWidth - stringWidth) / 2f, y, - 0xFFFFFFFF, - true, - new Matrix4f(), - guiGraphics.bufferSource(), - DisplayMode.NORMAL, - 0, - 255 + 0xFFFFFFFF ); } } diff --git a/platforms/fabric/src/main/java/net/lostluma/dynamic_fps/impl/fabric/mixin/GuiMixin.java b/platforms/fabric/src/main/java/net/lostluma/dynamic_fps/impl/fabric/mixin/GuiMixin.java new file mode 100644 index 00000000..34e2e9ab --- /dev/null +++ b/platforms/fabric/src/main/java/net/lostluma/dynamic_fps/impl/fabric/mixin/GuiMixin.java @@ -0,0 +1,27 @@ +package net.lostluma.dynamic_fps.impl.fabric.mixin; + +import com.llamalad7.mixinextras.sugar.Local; +import com.mojang.blaze3d.vertex.PoseStack; +import dynamic_fps.impl.util.HudInfoRenderer; +import net.minecraft.client.gui.Gui; +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; + +@Mixin(Gui.class) +public class GuiMixin { + /** + * Render info on whether Dynamic FPS is disabled or always reducing the user's FPS. + */ + @Inject( + method = "render", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/gui/Gui;renderSavingIndicator(Lcom/mojang/blaze3d/vertex/PoseStack;)V" + ) + ) + private void render(CallbackInfo callbackInfo, @Local PoseStack poseStack) { + HudInfoRenderer.renderInfo(poseStack); + } +} diff --git a/platforms/fabric/src/main/resources/dynamic_fps.mixins.json b/platforms/fabric/src/main/resources/dynamic_fps.mixins.json index 0801d7a2..f9a16703 100644 --- a/platforms/fabric/src/main/resources/dynamic_fps.mixins.json +++ b/platforms/fabric/src/main/resources/dynamic_fps.mixins.json @@ -4,6 +4,7 @@ "compatibilityLevel": "JAVA_17", "minVersion": "0.8", "client": [ + "GuiMixin", "OptionsMixin" ], "mixins": [], diff --git a/platforms/fabric/src/main/resources/fabric.mod.json b/platforms/fabric/src/main/resources/fabric.mod.json index ee6e2c0a..aeeec202 100644 --- a/platforms/fabric/src/main/resources/fabric.mod.json +++ b/platforms/fabric/src/main/resources/fabric.mod.json @@ -27,7 +27,7 @@ }, "depends": { "fabricloader": ">=0.15.0", - "minecraft": ">=1.20.0", + "minecraft": "=1.19.3", "mixinextras": ">=0.3.2", "fabric-resource-loader-v0": "*", "fabric-lifecycle-events-v1": "*" diff --git a/platforms/forge/src/main/java/net/lostluma/dynamic_fps/impl/forge/DynamicFPSForgeMod.java b/platforms/forge/src/main/java/net/lostluma/dynamic_fps/impl/forge/DynamicFPSForgeMod.java index d1a2f8bf..86879213 100644 --- a/platforms/forge/src/main/java/net/lostluma/dynamic_fps/impl/forge/DynamicFPSForgeMod.java +++ b/platforms/forge/src/main/java/net/lostluma/dynamic_fps/impl/forge/DynamicFPSForgeMod.java @@ -38,9 +38,15 @@ public DynamicFPSForgeMod() { ); MinecraftForge.EVENT_BUS.addListener(this::onClientTick); + MinecraftForge.EVENT_BUS.addListener(this::renderGuiOverlay); + FMLJavaModLoadingContext.get().getModEventBus().addListener(this::registerKeyMappings); } + public void renderGuiOverlay(RenderGuiOverlayEvent event) { + HudInfoRenderer.renderInfo(event.getPoseStack()); + } + public void registerKeyMappings(RegisterKeyMappingsEvent event) { for (KeyMappingHandler handler : KeyMappingHandler.getHandlers()) { event.register(handler.keyMapping()); diff --git a/platforms/forge/src/main/resources/META-INF/mods.toml b/platforms/forge/src/main/resources/META-INF/mods.toml index fd16cdc9..603bd191 100644 --- a/platforms/forge/src/main/resources/META-INF/mods.toml +++ b/platforms/forge/src/main/resources/META-INF/mods.toml @@ -26,7 +26,7 @@ file="META-INF/accesstransformer.cfg" [[dependencies.dynamic_fps]] modId = "minecraft" mandatory = true -versionRange = "[1.20.0,)" +versionRange = "[1.19.3]" ordering = "NONE" side = "CLIENT" diff --git a/platforms/quilt/src/main/java/net/lostluma/dynamic_fps/impl/quilt/mixin/GuiMixin.java b/platforms/quilt/src/main/java/net/lostluma/dynamic_fps/impl/quilt/mixin/GuiMixin.java new file mode 100644 index 00000000..aecc8c76 --- /dev/null +++ b/platforms/quilt/src/main/java/net/lostluma/dynamic_fps/impl/quilt/mixin/GuiMixin.java @@ -0,0 +1,27 @@ +package net.lostluma.dynamic_fps.impl.quilt.mixin; + +import com.llamalad7.mixinextras.sugar.Local; +import com.mojang.blaze3d.vertex.PoseStack; +import dynamic_fps.impl.util.HudInfoRenderer; +import net.minecraft.client.gui.Gui; +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; + +@Mixin(Gui.class) +public class GuiMixin { + /** + * Render info on whether Dynamic FPS is disabled or always reducing the user's FPS. + */ + @Inject( + method = "render", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/gui/Gui;renderSavingIndicator(Lcom/mojang/blaze3d/vertex/PoseStack;)V" + ) + ) + private void render(CallbackInfo callbackInfo, @Local PoseStack poseStack) { + HudInfoRenderer.renderInfo(poseStack); + } +} diff --git a/platforms/quilt/src/main/resources/dynamic_fps.mixins.json b/platforms/quilt/src/main/resources/dynamic_fps.mixins.json index b3d28cf8..603b6b5c 100644 --- a/platforms/quilt/src/main/resources/dynamic_fps.mixins.json +++ b/platforms/quilt/src/main/resources/dynamic_fps.mixins.json @@ -4,6 +4,7 @@ "compatibilityLevel": "JAVA_17", "minVersion": "0.8", "client": [ + "GuiMixin", "OptionsMixin" ], "mixins": [], diff --git a/platforms/quilt/src/main/resources/quilt.mod.json b/platforms/quilt/src/main/resources/quilt.mod.json index e9f6eb80..89978869 100644 --- a/platforms/quilt/src/main/resources/quilt.mod.json +++ b/platforms/quilt/src/main/resources/quilt.mod.json @@ -40,7 +40,7 @@ }, { "id": "minecraft", - "versions": ">=1.20.0" + "versions": "=1.19.3" }, { "id": "mixinextras", diff --git a/settings.gradle b/settings.gradle index 46efda2c..c8225e94 100644 --- a/settings.gradle +++ b/settings.gradle @@ -12,5 +12,5 @@ rootProject.name = "dynamic-fps" include(":platforms:common") include(":platforms:fabric") include(":platforms:forge") -include(":platforms:neoforge") +// include(":platforms:neoforge") include(":platforms:quilt")