From 06804675be18c612138a713aca1a5801a7e5dbf8 Mon Sep 17 00:00:00 2001 From: LexManos Date: Wed, 4 Aug 2021 01:05:02 -0700 Subject: [PATCH] Add forceSystemNanoTime config option to the client. Normally glfwGetTime is used, but in some cases it may have performance issues. --- .../minecraftforge/fml/loading/LibraryFinder.java | 3 --- .../net/minecraft/client/Minecraft.java.patch | 8 ++++++++ .../net/minecraftforge/common/ForgeConfig.java | 14 +++++++++----- src/main/resources/assets/forge/lang/en_us.json | 2 ++ 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/LibraryFinder.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/LibraryFinder.java index 8332ed38cf..66b23660f9 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/LibraryFinder.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/LibraryFinder.java @@ -93,7 +93,4 @@ public class LibraryFinder { public static Path findPathForMaven(final String maven) { return findLibsPath().resolve(MavenCoordinateResolver.get(maven)); } - public static Path getFMLCorePath() { - return findLibsPath().resolve(MavenCoordinateResolver.get("net.minecraftforge:fmlcore:1.0")); - } } diff --git a/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/patches/minecraft/net/minecraft/client/Minecraft.java.patch index 5f9d41700f..4193267e0b 100644 --- a/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -24,6 +24,14 @@ this.f_91033_ = p_91084_.f_101908_.f_101926_; this.f_91034_ = !p_91084_.f_101908_.f_101929_; this.f_91035_ = !p_91084_.f_101908_.f_101930_; +@@ -436,6 +_,7 @@ + } + + Util.f_137440_ = RenderSystem.m_69576_(); ++ if (net.minecraftforge.common.ForgeConfig.CLIENT.forceSystemNanoTime.get()) Util.f_137440_ = System::nanoTime; + this.f_90989_ = new VirtualScreen(this); + this.f_90990_ = this.f_90989_.m_110872_(displaydata, this.f_91066_.f_92123_, this.m_91270_()); + this.m_7440_(true); @@ -450,7 +_,6 @@ this.f_90990_.m_85380_(this.f_91066_.f_92113_); diff --git a/src/main/java/net/minecraftforge/common/ForgeConfig.java b/src/main/java/net/minecraftforge/common/ForgeConfig.java index 9b1554c235..d5a4632006 100644 --- a/src/main/java/net/minecraftforge/common/ForgeConfig.java +++ b/src/main/java/net/minecraftforge/common/ForgeConfig.java @@ -28,10 +28,8 @@ import org.apache.logging.log4j.LogManager; import net.minecraftforge.common.ForgeConfigSpec.BooleanValue; import net.minecraftforge.common.ForgeConfigSpec.DoubleValue; -import net.minecraftforge.common.ForgeConfigSpec.IntValue; -public class ForgeConfig -{ +public class ForgeConfig { public static class Server { public final BooleanValue removeErroringBlockEntities; @@ -92,8 +90,7 @@ public class ForgeConfig public static class Common { public final ForgeConfigSpec.ConfigValue defaultWorldType; - Common(ForgeConfigSpec.Builder builder) - { + Common(ForgeConfigSpec.Builder builder) { builder.comment("General configuration settings") .push("general"); @@ -122,6 +119,8 @@ public class ForgeConfig public final BooleanValue useCombinedDepthStencilAttachment; + public final BooleanValue forceSystemNanoTime; + Client(ForgeConfigSpec.Builder builder) { builder.comment("Client only settings, mostly things related to rendering") .push("client"); @@ -153,6 +152,11 @@ public class ForgeConfig .translation("forge.configgui.useCombinedDepthStencilAttachment") .define("useCombinedDepthStencilAttachment", false); + forceSystemNanoTime = builder + .comment("Forces the use of System.nanoTime instead of glfwGetTime, as the main Util time provider") + .translation("forge.configgui.forceSystemNanoTime") + .define("forceSystemNanoTime", false); + builder.pop(); } } diff --git a/src/main/resources/assets/forge/lang/en_us.json b/src/main/resources/assets/forge/lang/en_us.json index fd00753e0e..a1d110943e 100644 --- a/src/main/resources/assets/forge/lang/en_us.json +++ b/src/main/resources/assets/forge/lang/en_us.json @@ -141,6 +141,8 @@ "forge.configgui.clumpingThreshold": "Packet Clumping Threshold", "forge.configgui.treatEmptyTagsAsAir.tooltip": "Vanilla will treat crafting recipes using empty tags as air, and allow you to craft with nothing in that slot. This changes empty tags to use BARRIER as the item. To prevent crafting with air.", "forge.configgui.treatEmptyTagsAsAir": "Treat empty tags as air", + "forge.configgui.forceSystemNanoTime.tooltip": "Force the use of System.nanoTime instead of glfwGetTime as the main client Time provider.", + "forge.configgui.forceSystemNanoTime": "Force System.nanoTime", "forge.configgui.zoomInMissingModelTextInGui.tooltip": "Toggle off to make missing model text in the gui fit inside the slot.", "forge.configgui.zoomInMissingModelTextInGui": "Zoom in Missing model text in the GUI",