From f27d6e154c2c5badab3eefe4b75f394a6e027c7a Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Fri, 7 Jul 2023 20:19:08 -0400 Subject: [PATCH 1/2] Make disabling feature.measure_time also disable game/world load messages --- .../src/main/java/org/embeddedt/modernfix/ModernFix.java | 3 ++- .../java/org/embeddedt/modernfix/ModernFixClient.java | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/org/embeddedt/modernfix/ModernFix.java b/common/src/main/java/org/embeddedt/modernfix/ModernFix.java index d09454bd..d2bc73d0 100644 --- a/common/src/main/java/org/embeddedt/modernfix/ModernFix.java +++ b/common/src/main/java/org/embeddedt/modernfix/ModernFix.java @@ -70,7 +70,8 @@ public class ModernFix { public void onServerStarted() { if(ModernFixPlatformHooks.isDedicatedServer()) { float gameStartTime = ManagementFactory.getRuntimeMXBean().getUptime() / 1000f; - ModernFix.LOGGER.warn("Dedicated server took " + gameStartTime + " seconds to load"); + if(ModernFixMixinPlugin.instance.isOptionEnabled("feature.measure_time.ServerLoad")) + ModernFix.LOGGER.warn("Dedicated server took " + gameStartTime + " seconds to load"); ModernFixPlatformHooks.onLaunchComplete(); } ClassInfoManager.clear(); diff --git a/common/src/main/java/org/embeddedt/modernfix/ModernFixClient.java b/common/src/main/java/org/embeddedt/modernfix/ModernFixClient.java index 74450b24..cca96b4a 100644 --- a/common/src/main/java/org/embeddedt/modernfix/ModernFixClient.java +++ b/common/src/main/java/org/embeddedt/modernfix/ModernFixClient.java @@ -65,7 +65,8 @@ public class ModernFixClient { worldLoadStartTime = System.nanoTime(); } else if (openingScreen instanceof TitleScreen && gameStartTimeSeconds < 0) { gameStartTimeSeconds = ManagementFactory.getRuntimeMXBean().getUptime() / 1000f; - ModernFix.LOGGER.warn("Game took " + gameStartTimeSeconds + " seconds to start"); + if(ModernFixMixinPlugin.instance.isOptionEnabled("feature.measure_time.GameLoad")) + ModernFix.LOGGER.warn("Game took " + gameStartTimeSeconds + " seconds to start"); ModernFixPlatformHooks.onLaunchComplete(); ClassInfoManager.clear(); } @@ -86,8 +87,10 @@ public class ModernFixClient { && Minecraft.getInstance().player != null && numRenderTicks++ >= 10) { float timeSpentLoading = ((float)(System.nanoTime() - worldLoadStartTime) / 1000000000f); - ModernFix.LOGGER.warn("Time from main menu to in-game was " + timeSpentLoading + " seconds"); - ModernFix.LOGGER.warn("Total time to load game and open world was " + (timeSpentLoading + gameStartTimeSeconds) + " seconds"); + if(ModernFixMixinPlugin.instance.isOptionEnabled("feature.measure_time.WorldLoad")) { + ModernFix.LOGGER.warn("Time from main menu to in-game was " + timeSpentLoading + " seconds"); + ModernFix.LOGGER.warn("Total time to load game and open world was " + (timeSpentLoading + gameStartTimeSeconds) + " seconds"); + } resetWorldLoadStateMachine(); } } From f3a2ca73e88374d6367e02a2556e9901cf286df4 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Fri, 7 Jul 2023 20:23:10 -0400 Subject: [PATCH 2/2] Log all option overrides once at startup rather than per mixin --- .../modernfix/core/ModernFixMixinPlugin.java | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/common/src/main/java/org/embeddedt/modernfix/core/ModernFixMixinPlugin.java b/common/src/main/java/org/embeddedt/modernfix/core/ModernFixMixinPlugin.java index 850db8f2..c27995f1 100644 --- a/common/src/main/java/org/embeddedt/modernfix/core/ModernFixMixinPlugin.java +++ b/common/src/main/java/org/embeddedt/modernfix/core/ModernFixMixinPlugin.java @@ -34,6 +34,21 @@ public class ModernFixMixinPlugin implements IMixinConfigPlugin { this.logger.info("Loaded configuration file for ModernFix: {} options available, {} override(s) found", config.getOptionCount(), config.getOptionOverrideCount()); + config.getOptionMap().values().forEach(option -> { + if (option.isOverridden()) { + String source = "[unknown]"; + + if (option.isUserDefined()) { + source = "user configuration"; + } else if (option.isModDefined()) { + source = "mods [" + String.join(", ", option.getDefiningMods()) + "]"; + } + this.logger.warn("Option '{}' overriden (by {}) to '{}'", option.getName(), + source, option.isEnabled()); + } + }); + + if(ModernFixEarlyConfig.OPTIFINE_PRESENT) this.logger.fatal("OptiFine detected. Use of ModernFix with OptiFine is not supported due to its impact on launch time and breakage of Forge features."); @@ -87,24 +102,6 @@ public class ModernFixMixinPlugin implements IMixinConfigPlugin { return false; } - if (option.isOverridden()) { - String source = "[unknown]"; - - if (option.isUserDefined()) { - source = "user configuration"; - } else if (option.isModDefined()) { - source = "mods [" + String.join(", ", option.getDefiningMods()) + "]"; - } - - if (option.isEnabled()) { - this.logger.warn("Force-enabling mixin '{}' as rule '{}' (added by {}) enables it", mixin, - option.getName(), source); - } else { - this.logger.warn("Force-disabling mixin '{}' as rule '{}' (added by {}) disables it and children", mixin, - option.getName(), source); - } - } - return option.isEnabled(); } @Override