From f1d4f030159a3b2c4187cb4342859acf621fc3a5 Mon Sep 17 00:00:00 2001 From: LostLuma Date: Sat, 17 Feb 2024 19:48:30 +0100 Subject: [PATCH] 1.16.5 NOTE: HUD overlay and debug overlay info doesn't render on Forge. --- build.gradle | 4 +- gradle/libs.versions.toml | 22 +-- .../dynamic_fps/impl/compat/ClothConfig.java | 133 +++++++++--------- .../java/dynamic_fps/impl/mixin/GuiMixin.java | 16 --- .../impl/mixin/MinecraftMixin.java | 2 +- .../impl/mixin/ToastComponentMixin.java | 14 +- .../dynamic_fps/impl/service/Services.java | 9 +- .../impl/util/HudInfoRenderer.java | 23 ++- .../dynamic_fps/impl/util/Localization.java | 4 +- .../java/dynamic_fps/impl/util/Logging.java | 6 +- .../dynamic_fps/impl/util/OptionsHolder.java | 41 +++--- .../resources/dynamic_fps-common.mixins.json | 2 +- .../impl/fabric/mixin/GuiMixin.java | 27 ++++ .../main/resources/dynamic_fps.mixins.json | 3 +- .../fabric/src/main/resources/fabric.mod.json | 4 +- platforms/forge/build.gradle | 2 + .../impl/forge/DynamicFPSForgeMod.java | 26 ++-- .../impl/forge/mixin/GameRendererMixin.java | 39 +++++ .../src/main/resources/META-INF/mods.toml | 7 +- .../main/resources/dynamic_fps.mixins.json | 6 +- .../forge/src/main/resources/dynamic_fps.png | Bin 0 -> 6871 bytes .../main/resources/dynamic_fps.mixins.json | 2 +- .../impl/quilt/mixin/GuiMixin.java | 27 ++++ .../main/resources/dynamic_fps.mixins.json | 3 +- .../quilt/src/main/resources/quilt.mod.json | 4 +- settings.gradle | 4 +- 26 files changed, 253 insertions(+), 177 deletions(-) create mode 100644 platforms/fabric/src/main/java/net/lostluma/dynamic_fps/impl/fabric/mixin/GuiMixin.java create mode 100644 platforms/forge/src/main/java/net/lostluma/dynamic_fps/impl/forge/mixin/GameRendererMixin.java create mode 100644 platforms/forge/src/main/resources/dynamic_fps.png create mode 100644 platforms/quilt/src/main/java/net/lostluma/dynamic_fps/impl/quilt/mixin/GuiMixin.java diff --git a/build.gradle b/build.gradle index c8c515ac..f11ed313 100644 --- a/build.gradle +++ b/build.gradle @@ -58,7 +58,7 @@ allprojects { withSourcesJar() toolchain { - languageVersion = JavaLanguageVersion.of(17) + languageVersion = JavaLanguageVersion.of(8) } } @@ -66,7 +66,7 @@ allprojects { it.options.encoding = "UTF-8" javaCompiler = javaToolchains.compilerFor { - languageVersion = JavaLanguageVersion.of(17) + languageVersion = JavaLanguageVersion.of(8) } } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d6fea4e4..b46a2e34 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,22 +1,22 @@ [versions] -minecraft = "1.20.4" +minecraft = "1.16.5" # Platform libraries fabric_loader = "0.15.6" -fabric_api = "0.96.1+1.20.4" +fabric_api = "0.29.4+1.16" -forge = "1.20.4-49.0.30" +forge = "1.16.5-36.2.41" -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_loader = "0.23.1" +# quilt_standard_libraries = "1.1.0-beta.26+1.18.2" # Third-party libraries -modmenu = "9.0.0" -cloth_config = "13.0.121" +modmenu = "1.16.23" +cloth_config = "4.17.101" mixinextras = "0.3.5" @@ -30,10 +30,10 @@ 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" } +# 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" } # Third-party 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..547d22c3 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,8 +10,9 @@ 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.network.chat.TextComponent; +import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.sounds.SoundSource; import java.util.Locale; @@ -34,40 +35,40 @@ public static Screen genConfigScreen(Screen parent) { general.addEntry( entryBuilder.startBooleanToggle( - localized("config", "enabled"), - DynamicFPSMod.modConfig.enabled() - ) - .setDefaultValue(true) - .setSaveConsumer(DynamicFPSMod.modConfig::setEnabled) - .build() + localized("config", "enabled"), + DynamicFPSMod.modConfig.enabled() + ) + .setDefaultValue(true) + .setSaveConsumer(DynamicFPSMod.modConfig::setEnabled) + .build() ); general.addEntry( - entryBuilder.startTextDescription(CommonComponents.SPACE).build() + entryBuilder.startTextDescription(new TextComponent(" ")).build() ); general.addEntry( entryBuilder.startIntSlider( - localized("config", "idle_time"), - DynamicFPSMod.modConfig.idleTime() / 60, - 0, 30 - ) - .setDefaultValue(0) - .setSaveConsumer(value -> DynamicFPSMod.modConfig.setIdleTime(value * 60)) - .setTextGetter(ClothConfig::idleTimeMessage) - .setTooltip(localized("config", "idle_time_tooltip")) - .build() + localized("config", "idle_time"), + DynamicFPSMod.modConfig.idleTime() / 60, + 0, 30 + ) + .setDefaultValue(0) + .setSaveConsumer(value -> DynamicFPSMod.modConfig.setIdleTime(value * 60)) + .setTextGetter(ClothConfig::idleTimeMessage) + .setTooltip(localized("config", "idle_time_tooltip")) + .build() ); general.addEntry( entryBuilder.startBooleanToggle( - localized("config", "uncap_menu_frame_rate"), - DynamicFPSMod.modConfig.uncapMenuFrameRate() - ) - .setDefaultValue(false) - .setSaveConsumer(DynamicFPSMod.modConfig::setUncapMenuFrameRate) - .setTooltip(localized("config", "uncap_menu_frame_rate_tooltip")) - .build() + localized("config", "uncap_menu_frame_rate"), + DynamicFPSMod.modConfig.uncapMenuFrameRate() + ) + .setDefaultValue(false) + .setSaveConsumer(DynamicFPSMod.modConfig::setUncapMenuFrameRate) + .setTooltip(localized("config", "uncap_menu_frame_rate_tooltip")) + .build() ); for (PowerState state : PowerState.values()) { @@ -84,14 +85,14 @@ public static Screen genConfigScreen(Screen parent) { category.addEntry( entryBuilder.startIntSlider( - localized("config", "frame_rate_target"), - fromConfigFpsTarget(config.frameRateTarget()), - 0, 61 - ) - .setDefaultValue(fromConfigFpsTarget(standard.frameRateTarget())) - .setSaveConsumer(value -> config.setFrameRateTarget(toConfigFpsTarget(value))) - .setTextGetter(ClothConfig::fpsTargetMessage) - .build() + localized("config", "frame_rate_target"), + fromConfigFpsTarget(config.frameRateTarget()), + 0, 61 + ) + .setDefaultValue(fromConfigFpsTarget(standard.frameRateTarget())) + .setSaveConsumer(value -> config.setFrameRateTarget(toConfigFpsTarget(value))) + .setTextGetter(ClothConfig::fpsTargetMessage) + .build() ); SubCategoryBuilder volumes = entryBuilder.startSubCategory(localized("config", "volume_multiplier")); @@ -101,14 +102,14 @@ public static Screen genConfigScreen(Screen parent) { volumes.add( entryBuilder.startIntSlider( - Component.translatable("soundCategory." + name), - (int) (config.volumeMultiplier(source) * 100), - 0, 100 - ) - .setDefaultValue((int) (standard.volumeMultiplier(source) * 100)) - .setSaveConsumer(value -> config.setVolumeMultiplier(source, value / 100f)) - .setTextGetter(ClothConfig::volumeMultiplierMessage) - .build() + new TranslatableComponent("soundCategory." + name), + (int) (config.volumeMultiplier(source) * 100), + 0, 100 + ) + .setDefaultValue((int) (standard.volumeMultiplier(source) * 100)) + .setSaveConsumer(value -> config.setVolumeMultiplier(source, value / 100f)) + .setTextGetter(ClothConfig::volumeMultiplierMessage) + .build() ); } @@ -116,37 +117,37 @@ public static Screen genConfigScreen(Screen parent) { category.addEntry( entryBuilder.startEnumSelector( - localized("config", "graphics_state"), - GraphicsState.class, - config.graphicsState() - ) - .setDefaultValue(standard.graphicsState()) - .setSaveConsumer(config::setGraphicsState) - .setEnumNameProvider(ClothConfig::graphicsStateMessage) - .setTooltipSupplier(ClothConfig::graphicsStateTooltip) - .build() + localized("config", "graphics_state"), + GraphicsState.class, + config.graphicsState() + ) + .setDefaultValue(standard.graphicsState()) + .setSaveConsumer(config::setGraphicsState) + .setEnumNameProvider(ClothConfig::graphicsStateMessage) + .setTooltipSupplier((current) -> ClothConfig.graphicsStateTooltip((GraphicsState) current)) // wth + .build() ); category.addEntry( entryBuilder.startBooleanToggle( - localized("config", "show_toasts"), - config.showToasts() - ) - .setDefaultValue(standard.showToasts()) - .setSaveConsumer(config::setShowToasts) - .setTooltip(localized("config", "show_toasts_tooltip")) - .build() + localized("config", "show_toasts"), + config.showToasts() + ) + .setDefaultValue(standard.showToasts()) + .setSaveConsumer(config::setShowToasts) + .setTooltip(localized("config", "show_toasts_tooltip")) + .build() ); category.addEntry( entryBuilder.startBooleanToggle( - localized("config", "run_garbage_collector"), - config.runGarbageCollector() - ) - .setDefaultValue(standard.runGarbageCollector()) - .setSaveConsumer(config::setRunGarbageCollector) - .setTooltip(localized("config", "run_garbage_collector_tooltip")) - .build() + localized("config", "run_garbage_collector"), + config.runGarbageCollector() + ) + .setDefaultValue(standard.runGarbageCollector()) + .setSaveConsumer(config::setRunGarbageCollector) + .setTooltip(localized("config", "run_garbage_collector_tooltip")) + .build() ); } @@ -173,14 +174,14 @@ private static int fromConfigFpsTarget(int value) { private static Component fpsTargetMessage(int value) { if (toConfigFpsTarget(value) != -1) { - return Component.translatable("options.framerate", value); + return new TranslatableComponent("options.framerate", value); } else { - return Component.translatable("options.framerateLimit.max"); + return new TranslatableComponent("options.framerateLimit.max"); } } private static Component volumeMultiplierMessage(int value) { - return Component.literal(Integer.toString(value) + "%"); + return new TextComponent(Integer.toString(value) + "%"); } private static Component graphicsStateMessage(Enum graphicsState) { 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/MinecraftMixin.java b/platforms/common/src/main/java/dynamic_fps/impl/mixin/MinecraftMixin.java index e314d8d2..e8573934 100644 --- a/platforms/common/src/main/java/dynamic_fps/impl/mixin/MinecraftMixin.java +++ b/platforms/common/src/main/java/dynamic_fps/impl/mixin/MinecraftMixin.java @@ -52,7 +52,7 @@ private void getFramerateLimit(CallbackInfoReturnable callbackInfo) { callbackInfo.setReturnValue(limit); } } else if (DynamicFPSMod.uncapMenuFrameRate()) { - if (self.options.enableVsync().get()) { + if (self.options.enableVsync) { // VSync will regulate to a non-infinite value callbackInfo.setReturnValue(NO_FRAME_RATE_LIMIT); } else { 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/service/Services.java b/platforms/common/src/main/java/dynamic_fps/impl/service/Services.java index 2b8e5bc5..76c5095c 100644 --- a/platforms/common/src/main/java/dynamic_fps/impl/service/Services.java +++ b/platforms/common/src/main/java/dynamic_fps/impl/service/Services.java @@ -1,5 +1,6 @@ package dynamic_fps.impl.service; +import java.util.NoSuchElementException; import java.util.Optional; import java.util.ServiceLoader; @@ -8,11 +9,9 @@ class Services { static ModCompat MOD_COMPAT = loadService(ModCompat.class); static T loadService(Class type) { - Optional optional = ServiceLoader.load(type).findFirst(); - - if (optional.isPresent()) { - return optional.get(); - } else { + try { + return ServiceLoader.load(type).iterator().next(); + } catch (NoSuchElementException e) { throw new RuntimeException("Failed to load Dynamic FPS " + type.getSimpleName() + " service!"); } } 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/common/src/main/java/dynamic_fps/impl/util/Localization.java b/platforms/common/src/main/java/dynamic_fps/impl/util/Localization.java index bd3d95e0..0fd1579e 100644 --- a/platforms/common/src/main/java/dynamic_fps/impl/util/Localization.java +++ b/platforms/common/src/main/java/dynamic_fps/impl/util/Localization.java @@ -1,8 +1,8 @@ package dynamic_fps.impl.util; import dynamic_fps.impl.Constants; -import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.TranslatableComponent; public final class Localization { /** e.g. keyString("title", "config") -> "title.dynamic_fps.config") */ @@ -11,7 +11,7 @@ public static String translationKey(String domain, String path) { } public static MutableComponent localized(String domain, String path, Object... args) { - return Component.translatable(translationKey(domain, path), args); + return new TranslatableComponent(translationKey(domain, path), args); } private Localization() {} diff --git a/platforms/common/src/main/java/dynamic_fps/impl/util/Logging.java b/platforms/common/src/main/java/dynamic_fps/impl/util/Logging.java index f510adfb..a0911c62 100644 --- a/platforms/common/src/main/java/dynamic_fps/impl/util/Logging.java +++ b/platforms/common/src/main/java/dynamic_fps/impl/util/Logging.java @@ -1,11 +1,11 @@ package dynamic_fps.impl.util; import dynamic_fps.impl.Constants; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; public class Logging { - private static final Logger logger = LoggerFactory.getLogger(Constants.MOD_ID); + private static final Logger logger = LogManager.getLogger(Constants.MOD_ID); public static Logger getLogger() { return logger; diff --git a/platforms/common/src/main/java/dynamic_fps/impl/util/OptionsHolder.java b/platforms/common/src/main/java/dynamic_fps/impl/util/OptionsHolder.java index f22862e3..3c9799bc 100644 --- a/platforms/common/src/main/java/dynamic_fps/impl/util/OptionsHolder.java +++ b/platforms/common/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,10 +15,10 @@ 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; + private static float entityDistance; /* * Create an in-memory copy of current vanilla graphics options. @@ -25,12 +26,12 @@ public class OptionsHolder { * This MUST be called while graphics options have not been changed yet. */ public static void copyOptions(Options options) { - cloudStatus = options.getCloudsType(); - graphicsStatus = options.graphicsMode().get(); - ambientOcclusion = options.ambientOcclusion().get(); - particlesStatus = options.particles().get(); - entityShadows = options.entityShadows().get(); - entityDistance = options.entityDistanceScaling().get(); + cloudStatus = options.renderClouds; + graphicsStatus = options.graphicsMode; + ambientOcclusion = options.ambientOcclusion; + particlesStatus = options.particles; + entityShadows = options.entityShadows; + entityDistance = options.entityDistanceScaling; } /* @@ -38,21 +39,21 @@ public static void copyOptions(Options options) { */ public static void applyOptions(Options options, GraphicsState state) { if (state == GraphicsState.DEFAULT) { - options.cloudStatus().set(cloudStatus); - options.graphicsMode().set(graphicsStatus); - options.ambientOcclusion().set(ambientOcclusion); - options.particles().set(particlesStatus); - options.entityShadows().set(entityShadows); - options.entityDistanceScaling().set(entityDistance); + options.renderClouds = cloudStatus; + options.graphicsMode = graphicsStatus; + options.ambientOcclusion = ambientOcclusion; + options.particles = particlesStatus; + options.entityShadows = entityShadows; + options.entityDistanceScaling = entityDistance; } else { // state == GraphicsState.REDUCED - options.cloudStatus().set(CloudStatus.OFF); - options.particles().set(ParticleStatus.MINIMAL); - options.entityShadows().set(false); - options.entityDistanceScaling().set(0.5); + options.renderClouds = CloudStatus.OFF; + options.particles = ParticleStatus.MINIMAL; + options.entityShadows = false; + options.entityDistanceScaling = 0.5f; if (state == GraphicsState.MINIMAL) { - options.graphicsMode().set(GraphicsStatus.FAST); - options.ambientOcclusion().set(false); + options.graphicsMode = GraphicsStatus.FAST; + options.ambientOcclusion = AmbientOcclusionStatus.OFF; } } } diff --git a/platforms/common/src/main/resources/dynamic_fps-common.mixins.json b/platforms/common/src/main/resources/dynamic_fps-common.mixins.json index 33486bf4..8a258846 100644 --- a/platforms/common/src/main/resources/dynamic_fps-common.mixins.json +++ b/platforms/common/src/main/resources/dynamic_fps-common.mixins.json @@ -1,7 +1,7 @@ { "required": true, "package": "dynamic_fps.impl.mixin", - "compatibilityLevel": "JAVA_17", + "compatibilityLevel": "JAVA_8", "minVersion": "0.8", "client": [ "DebugScreenOverlayMixin", 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..b0e54663 --- /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;renderHotbar(FLcom/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..7610a86c 100644 --- a/platforms/fabric/src/main/resources/dynamic_fps.mixins.json +++ b/platforms/fabric/src/main/resources/dynamic_fps.mixins.json @@ -1,9 +1,10 @@ { "required": true, "package": "net.lostluma.dynamic_fps.impl.fabric.mixin", - "compatibilityLevel": "JAVA_17", + "compatibilityLevel": "JAVA_8", "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..a5cc7c00 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.16.5", "mixinextras": ">=0.3.2", "fabric-resource-loader-v0": "*", "fabric-lifecycle-events-v1": "*" @@ -58,7 +58,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" @@ -75,7 +74,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" diff --git a/platforms/forge/build.gradle b/platforms/forge/build.gradle index c7381cd6..6b0d3254 100644 --- a/platforms/forge/build.gradle +++ b/platforms/forge/build.gradle @@ -52,6 +52,8 @@ shadowJar { exclude "fabric.mod.json" exclude "architectury.common.json" + exclude "assets/dynamic_fps/icon.png" + configurations = [project.configurations.shadowCommon] } 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..cbcd7c5d 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 @@ -4,26 +4,28 @@ import dynamic_fps.impl.DynamicFPSMod; import dynamic_fps.impl.compat.ClothConfig; import dynamic_fps.impl.service.Platform; -import dynamic_fps.impl.util.HudInfoRenderer; import dynamic_fps.impl.util.KeyMappingHandler; -import net.minecraftforge.client.ConfigScreenHandler; -import net.minecraftforge.client.event.RegisterKeyMappingsEvent; -import net.minecraftforge.client.event.RenderGuiOverlayEvent; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.Screen; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.TickEvent; +import net.minecraftforge.fml.ExtensionPoint; import net.minecraftforge.fml.ModLoadingContext; +import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.loading.FMLLoader; import java.util.ArrayList; import java.util.List; +import java.util.function.BiFunction; @Mod(Constants.MOD_ID) public class DynamicFPSForgeMod { private static final List TICK_EVENT_LISTENERS = new ArrayList<>(); - public DynamicFPSForgeMod() { + public DynamicFPSForgeMod() { if (FMLLoader.getDist().isDedicatedServer()) { return; } @@ -31,19 +33,17 @@ public DynamicFPSForgeMod() { DynamicFPSMod.init(); ModLoadingContext.get().registerExtensionPoint( - ConfigScreenHandler.ConfigScreenFactory.class, - () -> new ConfigScreenHandler.ConfigScreenFactory( - (minecraft, screen) -> ClothConfig.genConfigScreen(screen) - ) - ); + ExtensionPoint.CONFIGGUIFACTORY, + () -> (minecraft, screen) -> ClothConfig.genConfigScreen(screen) + ); MinecraftForge.EVENT_BUS.addListener(this::onClientTick); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::registerKeyMappings); - } + } - public void registerKeyMappings(RegisterKeyMappingsEvent event) { + public void registerKeyMappings(FMLClientSetupEvent event) { for (KeyMappingHandler handler : KeyMappingHandler.getHandlers()) { - event.register(handler.keyMapping()); + ClientRegistry.registerKeyBinding(handler.keyMapping()); } } diff --git a/platforms/forge/src/main/java/net/lostluma/dynamic_fps/impl/forge/mixin/GameRendererMixin.java b/platforms/forge/src/main/java/net/lostluma/dynamic_fps/impl/forge/mixin/GameRendererMixin.java new file mode 100644 index 00000000..3422af32 --- /dev/null +++ b/platforms/forge/src/main/java/net/lostluma/dynamic_fps/impl/forge/mixin/GameRendererMixin.java @@ -0,0 +1,39 @@ +package net.lostluma.dynamic_fps.impl.forge.mixin; + +import dynamic_fps.impl.DynamicFPSMod; +import net.minecraft.Util; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GameRenderer; +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; + +@Mixin(GameRenderer.class) +public class GameRendererMixin { + @Shadow + @Final + private Minecraft minecraft; + + @Shadow + private long lastActiveTime; + + // Duplicate of common mixin w/o mixinextras and injected earlier + // Since the original just does not activate at all on Forge ...? + // We have to add the pause on lost focus feature ourselves sadly + @Inject(method = "render", at = @At("HEAD"), cancellable = true) + private void skipRendering(CallbackInfo callbackInfo) { + if (!DynamicFPSMod.checkForRender()) { + callbackInfo.cancel(); + + // Copy of vanilla code + if (this.minecraft.isWindowActive() || !this.minecraft.options.pauseOnLostFocus || this.minecraft.options.touchscreen && this.minecraft.mouseHandler.isRightPressed()) { + this.lastActiveTime = Util.getMillis(); + } else if (Util.getMillis() - this.lastActiveTime > 500L) { + this.minecraft.pauseGame(false); + } + } + } +} diff --git a/platforms/forge/src/main/resources/META-INF/mods.toml b/platforms/forge/src/main/resources/META-INF/mods.toml index fd16cdc9..6c8c8d92 100644 --- a/platforms/forge/src/main/resources/META-INF/mods.toml +++ b/platforms/forge/src/main/resources/META-INF/mods.toml @@ -5,12 +5,11 @@ issueTrackerURL = "https://github.com/juliand665/Dynamic-FPS/issues" [[mods]] modId = "dynamic_fps" -namespace = "net.lostluma" version = "${version}" displayName = "Dynamic FPS" authors = "juliand665 & LostLuma" description = "Dynamically adjusts FPS so Minecraft doesn't hog resources in the background." -logoFile = "assets/dynamic_fps/icon.png" +logoFile = "dynamic_fps.png" displayTest = "IGNORE_ALL_VERSION" updateJSONURL = "https://api.lostluma.net/updates/dynamic-fps?platform=forge" @@ -26,12 +25,12 @@ file="META-INF/accesstransformer.cfg" [[dependencies.dynamic_fps]] modId = "minecraft" mandatory = true -versionRange = "[1.20.0,)" +versionRange = "[1.16.5]" ordering = "NONE" side = "CLIENT" [[dependencies.dynamic_fps]] -modId = "cloth_config" +modId = "cloth-config" mandatory = true versionRange = "[1,)" ordering = "NONE" diff --git a/platforms/forge/src/main/resources/dynamic_fps.mixins.json b/platforms/forge/src/main/resources/dynamic_fps.mixins.json index 36a7f8d0..5cdc0608 100644 --- a/platforms/forge/src/main/resources/dynamic_fps.mixins.json +++ b/platforms/forge/src/main/resources/dynamic_fps.mixins.json @@ -1,9 +1,11 @@ { "required": true, "package": "net.lostluma.dynamic_fps.impl.forge.mixin", - "compatibilityLevel": "JAVA_17", + "compatibilityLevel": "JAVA_8", "minVersion": "0.8", - "client": [], + "client": [ + "GameRendererMixin" + ], "mixins": [], "server": [], "injectors": { diff --git a/platforms/forge/src/main/resources/dynamic_fps.png b/platforms/forge/src/main/resources/dynamic_fps.png new file mode 100644 index 0000000000000000000000000000000000000000..f282051920dd8187815d2c7347e9db3d1766fc9a GIT binary patch literal 6871 zcmV;|8Ytz7P)nLekmD8#tY-boY)MC zSWbKbnM5X&DZ*qjQEY}wV{;Rzl{ufJIvBeX z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ps.mixins.json index a1e30c92..859a3186 100644 --- a/platforms/neoforge/src/main/resources/dynamic_fps.mixins.json +++ b/platforms/neoforge/src/main/resources/dynamic_fps.mixins.json @@ -1,7 +1,7 @@ { "required": true, "package": "net.lostluma.dynamic_fps.impl.neoforge.mixin", - "compatibilityLevel": "JAVA_17", + "compatibilityLevel": "JAVA_8", "minVersion": "0.8", "client": [], "mixins": [], 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..674a64de 100644 --- a/platforms/quilt/src/main/resources/dynamic_fps.mixins.json +++ b/platforms/quilt/src/main/resources/dynamic_fps.mixins.json @@ -1,9 +1,10 @@ { "required": true, "package": "net.lostluma.dynamic_fps.impl.quilt.mixin", - "compatibilityLevel": "JAVA_17", + "compatibilityLevel": "JAVA_8", "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..965c1533 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.18.2" }, { "id": "mixinextras", @@ -89,7 +89,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" @@ -106,7 +105,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" diff --git a/settings.gradle b/settings.gradle index 46efda2c..50d9539e 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:quilt") +// include(":platforms:neoforge") +// include(":platforms:quilt")