From 05a885cb46853805e696dc32d342215628eec200 Mon Sep 17 00:00:00 2001 From: MrMangoHands Date: Fri, 16 Aug 2024 23:47:16 -0700 Subject: [PATCH] Split leftover platform specific code out of common, fixes remaining warnings --- .../core/render/world/LevelRendererMixin.java | 17 ------- .../ItemBlockRenderTypesMixin.java | 4 +- .../context_creation/WindowMixin.java | 51 +------------------ common/src/main/resources/sodium.mixins.json | 2 - .../mixin/fabric}/core/WindowMixin.java | 8 ++- .../hooks/settings/OptionsScreenMixin.java | 7 +-- .../main/resources/sodium-fabric.mixins.json | 20 ++++---- .../core/render/world/LevelRendererMixin.java | 21 ++++++++ .../hooks/settings/OptionsScreenMixin.java | 24 +++++++++ .../ItemBlockRenderTypesMixin.java | 30 +++++++++++ .../context_creation/WindowMixin.java | 34 +++++++++++++ .../main/resources/sodium-forge.mixins.json | 4 ++ 12 files changed, 133 insertions(+), 89 deletions(-) rename {common/src/main/java/net/caffeinemc/mods/sodium/mixin => fabric/src/main/java/net/caffeinemc/mods/sodium/mixin/fabric}/core/WindowMixin.java (74%) rename {common/src/main/java/net/caffeinemc/mods/sodium/mixin => fabric/src/main/java/net/caffeinemc/mods/sodium/mixin/fabric}/features/gui/hooks/settings/OptionsScreenMixin.java (79%) create mode 100644 neoforge/src/main/java/net/caffeinemc/mods/sodium/neoforge/mixin/core/render/world/LevelRendererMixin.java create mode 100644 neoforge/src/main/java/net/caffeinemc/mods/sodium/neoforge/mixin/features/gui/hooks/settings/OptionsScreenMixin.java create mode 100644 neoforge/src/main/java/net/caffeinemc/mods/sodium/neoforge/mixin/features/options/render_layers/ItemBlockRenderTypesMixin.java create mode 100644 neoforge/src/main/java/net/caffeinemc/mods/sodium/neoforge/mixin/workarounds/context_creation/WindowMixin.java diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/render/world/LevelRendererMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/render/world/LevelRendererMixin.java index 1734557952..07ce4a03b2 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/render/world/LevelRendererMixin.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/render/world/LevelRendererMixin.java @@ -6,7 +6,6 @@ import net.caffeinemc.mods.sodium.client.render.SodiumWorldRenderer; import net.caffeinemc.mods.sodium.client.render.chunk.ChunkRenderMatrices; import net.caffeinemc.mods.sodium.client.render.viewport.ViewportProvider; -import net.caffeinemc.mods.sodium.client.services.PlatformLevelAccess; import net.caffeinemc.mods.sodium.client.services.PlatformLevelRenderHooks; import net.caffeinemc.mods.sodium.client.util.FlawlessFrames; import net.caffeinemc.mods.sodium.client.world.LevelRendererExtension; @@ -25,8 +24,6 @@ import net.minecraft.client.renderer.entity.EntityRenderDispatcher; import net.minecraft.core.BlockPos; import net.minecraft.server.level.BlockDestructionProgress; -import net.minecraft.world.level.block.entity.BlockEntity; -import org.jetbrains.annotations.Nullable; import org.joml.Matrix4f; import org.spongepowered.asm.mixin.*; import org.spongepowered.asm.mixin.injection.At; @@ -35,7 +32,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.SortedSet; -import java.util.function.Consumer; @Mixin(LevelRenderer.class) public abstract class LevelRendererMixin implements LevelRendererExtension { @@ -47,10 +43,6 @@ public abstract class LevelRendererMixin implements LevelRendererExtension { @Final private Long2ObjectMap> destructionProgress; - @Shadow - @Nullable - private ClientLevel level; - @Shadow private int ticks; @@ -211,15 +203,6 @@ private void onRenderBlockEntities(DeltaTracker deltaTracker, boolean bl, Camera this.renderer.renderBlockEntities(new PoseStack(), this.renderBuffers, this.destructionProgress, camera, deltaTracker.getGameTimeDeltaPartialTick(false)); } - // Exclusive to NeoForge, allow to fail. - @SuppressWarnings("all") - @Inject(method = "iterateVisibleBlockEntities", at = @At("HEAD"), cancellable = true, require = 0) - public void replaceBlockEntityIteration(Consumer blockEntityConsumer, CallbackInfo ci) { - ci.cancel(); - - this.renderer.iterateVisibleBlockEntities(blockEntityConsumer); - } - /** * @reason Replace the debug string * @author JellySquid diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/options/render_layers/ItemBlockRenderTypesMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/options/render_layers/ItemBlockRenderTypesMixin.java index 1bca2f0f73..89672a1942 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/options/render_layers/ItemBlockRenderTypesMixin.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/options/render_layers/ItemBlockRenderTypesMixin.java @@ -18,8 +18,8 @@ public class ItemBlockRenderTypesMixin { // getRenderLayers is a NeoForge only function required for the leaves to properly work. @SuppressWarnings("all") @Redirect( - method = { "getChunkRenderType", "getMovingBlockRenderType", "getRenderLayers" }, - at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/ItemBlockRenderTypes;renderCutout:Z"), require = 2) + method = { "getChunkRenderType", "getMovingBlockRenderType" }, + at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/ItemBlockRenderTypes;renderCutout:Z")) private static boolean redirectLeavesShouldBeFancy() { return leavesFancy; } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/workarounds/context_creation/WindowMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/workarounds/context_creation/WindowMixin.java index bb4ac80d6a..6f055b2c20 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/workarounds/context_creation/WindowMixin.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/workarounds/context_creation/WindowMixin.java @@ -1,7 +1,5 @@ package net.caffeinemc.mods.sodium.mixin.workarounds.context_creation; -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.mojang.blaze3d.platform.DisplayData; import com.mojang.blaze3d.platform.ScreenManager; import com.mojang.blaze3d.platform.Window; @@ -9,11 +7,7 @@ import net.caffeinemc.mods.sodium.client.compatibility.checks.PostLaunchChecks; import net.caffeinemc.mods.sodium.client.compatibility.checks.ModuleScanner; import net.caffeinemc.mods.sodium.client.compatibility.environment.GLContextInfo; -import net.caffeinemc.mods.sodium.client.compatibility.workarounds.Workarounds; -import net.caffeinemc.mods.sodium.client.compatibility.workarounds.nvidia.NvidiaWorkarounds; -import net.caffeinemc.mods.sodium.client.services.PlatformRuntimeInformation; import net.minecraft.Util; -import org.lwjgl.glfw.GLFW; import org.lwjgl.opengl.WGL; import org.lwjgl.system.MemoryUtil; import org.slf4j.Logger; @@ -23,14 +17,8 @@ import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.function.IntSupplier; -import java.util.function.LongSupplier; -import java.util.function.Supplier; - - @Mixin(Window.class) public class WindowMixin { @Shadow @@ -40,42 +28,7 @@ public class WindowMixin { @Unique private long wglPrevContext = MemoryUtil.NULL; - @Redirect(method = "", at = @At(value = "INVOKE", target = "Lorg/lwjgl/glfw/GLFW;glfwCreateWindow(IILjava/lang/CharSequence;JJ)J"), expect = 0, require = 0) - private long wrapGlfwCreateWindow(int width, int height, CharSequence title, long monitor, long share) { - final boolean applyNvidiaWorkarounds = Workarounds.isWorkaroundEnabled(Workarounds.Reference.NVIDIA_THREADED_OPTIMIZATIONS); - - if (applyNvidiaWorkarounds) { - NvidiaWorkarounds.install(); - } - - try { - return GLFW.glfwCreateWindow(width, height, title, monitor, share); - } finally { - if (applyNvidiaWorkarounds) { - NvidiaWorkarounds.uninstall(); - } - } - } - - @SuppressWarnings("all") - @WrapOperation(method = "", at = @At(value = "INVOKE", target = "Lnet/neoforged/fml/loading/ImmediateWindowHandler;setupMinecraftWindow(Ljava/util/function/IntSupplier;Ljava/util/function/IntSupplier;Ljava/util/function/Supplier;Ljava/util/function/LongSupplier;)J"), expect = 0, require = 0) - private long wrapGlfwCreateWindowForge(final IntSupplier width, final IntSupplier height, final Supplier title, final LongSupplier monitor, Operation op) { - final boolean applyNvidiaWorkarounds = Workarounds.isWorkaroundEnabled(Workarounds.Reference.NVIDIA_THREADED_OPTIMIZATIONS); - - if (applyNvidiaWorkarounds && !PlatformRuntimeInformation.getInstance().platformHasEarlyLoadingScreen()) { - NvidiaWorkarounds.install(); - } - - try { - return op.call(width, height, title, monitor); - } finally { - if (applyNvidiaWorkarounds) { - NvidiaWorkarounds.uninstall(); - } - } - } - - @Inject(method = "", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL;createCapabilities()Lorg/lwjgl/opengl/GLCapabilities;", shift = At.Shift.AFTER)) + @Inject(method = "", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL;createCapabilities()Lorg/lwjgl/opengl/GLCapabilities;", shift = At.Shift.AFTER, remap = false)) private void postContextReady(WindowEventHandler eventHandler, ScreenManager monitorTracker, DisplayData settings, String videoMode, String title, CallbackInfo ci) { GLContextInfo driver = GLContextInfo.create(); @@ -98,7 +51,7 @@ private void postContextReady(WindowEventHandler eventHandler, ScreenManager mon ModuleScanner.checkModules(); } - @Inject(method = "updateDisplay", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;flipFrame(J)V", shift = At.Shift.AFTER)) + @Inject(method = "updateDisplay", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;flipFrame(J)V", shift = At.Shift.AFTER, remap = false)) private void preSwapBuffers(CallbackInfo ci) { if (this.wglPrevContext == MemoryUtil.NULL) { // There is no prior recorded context. diff --git a/common/src/main/resources/sodium.mixins.json b/common/src/main/resources/sodium.mixins.json index e110e980ee..7f9d323a4b 100644 --- a/common/src/main/resources/sodium.mixins.json +++ b/common/src/main/resources/sodium.mixins.json @@ -11,7 +11,6 @@ }, "client": [ "core.MinecraftMixin", - "core.WindowMixin", "core.gui.LevelLoadStatusManagerMixin", "core.model.colors.BlockColorsMixin", "core.model.colors.ItemColorsMixin", @@ -35,7 +34,6 @@ "core.world.map.ClientLevelMixin", "features.gui.hooks.console.GameRendererMixin", "features.gui.hooks.debug.DebugScreenOverlayMixin", - "features.gui.hooks.settings.OptionsScreenMixin", "features.gui.screen.LevelLoadingScreenMixin", "features.options.overlays.GuiMixin", "features.options.render_layers.LeavesBlockMixin", diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/WindowMixin.java b/fabric/src/main/java/net/caffeinemc/mods/sodium/mixin/fabric/core/WindowMixin.java similarity index 74% rename from common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/WindowMixin.java rename to fabric/src/main/java/net/caffeinemc/mods/sodium/mixin/fabric/core/WindowMixin.java index 999262e84e..7c5eeaffa5 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/WindowMixin.java +++ b/fabric/src/main/java/net/caffeinemc/mods/sodium/mixin/fabric/core/WindowMixin.java @@ -1,21 +1,19 @@ -package net.caffeinemc.mods.sodium.mixin.core; +package net.caffeinemc.mods.sodium.mixin.fabric.core; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.mojang.blaze3d.platform.Window; import net.caffeinemc.mods.sodium.client.SodiumClientMod; import net.caffeinemc.mods.sodium.client.compatibility.workarounds.Workarounds; -import net.caffeinemc.mods.sodium.client.services.PlatformRuntimeInformation; import org.lwjgl.glfw.GLFW; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(Window.class) public class WindowMixin { - @WrapOperation(method = "", at = @At(value = "INVOKE", target = "Lorg/lwjgl/glfw/GLFW;glfwCreateWindow(IILjava/lang/CharSequence;JJ)J"), require = 0) + @WrapOperation(method = "", at = @At(value = "INVOKE", target = "Lorg/lwjgl/glfw/GLFW;glfwCreateWindow(IILjava/lang/CharSequence;JJ)J"), remap = false) public long setAdditionalWindowHints(int titleEncoded, int width, CharSequence height, long title, long monitor, Operation original) { - if (!PlatformRuntimeInformation.getInstance().platformHasEarlyLoadingScreen() && SodiumClientMod.options().performance.useNoErrorGLContext && + if (SodiumClientMod.options().performance.useNoErrorGLContext && !Workarounds.isWorkaroundEnabled(Workarounds.Reference.NO_ERROR_CONTEXT_UNSUPPORTED)) { GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_NO_ERROR, GLFW.GLFW_TRUE); } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/gui/hooks/settings/OptionsScreenMixin.java b/fabric/src/main/java/net/caffeinemc/mods/sodium/mixin/fabric/features/gui/hooks/settings/OptionsScreenMixin.java similarity index 79% rename from common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/gui/hooks/settings/OptionsScreenMixin.java rename to fabric/src/main/java/net/caffeinemc/mods/sodium/mixin/fabric/features/gui/hooks/settings/OptionsScreenMixin.java index 0e1c1d27ec..b172ecbb04 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/gui/hooks/settings/OptionsScreenMixin.java +++ b/fabric/src/main/java/net/caffeinemc/mods/sodium/mixin/fabric/features/gui/hooks/settings/OptionsScreenMixin.java @@ -1,4 +1,4 @@ -package net.caffeinemc.mods.sodium.mixin.features.gui.hooks.settings; +package net.caffeinemc.mods.sodium.mixin.fabric.features.gui.hooks.settings; import net.caffeinemc.mods.sodium.client.gui.SodiumOptionsGUI; import net.minecraft.client.gui.screens.Screen; @@ -17,10 +17,7 @@ protected OptionsScreenMixin(Component title) { } @Dynamic - @Inject(method = { - "method_19828", - "lambda$init$2" - }, require = 1, at = @At("HEAD"), cancellable = true) + @Inject(method = "method_19828", at = @At("HEAD"), cancellable = true) private void open(CallbackInfoReturnable ci) { ci.setReturnValue(SodiumOptionsGUI.createScreen(this)); } diff --git a/fabric/src/main/resources/sodium-fabric.mixins.json b/fabric/src/main/resources/sodium-fabric.mixins.json index f27a82fd62..69312d695b 100644 --- a/fabric/src/main/resources/sodium-fabric.mixins.json +++ b/fabric/src/main/resources/sodium-fabric.mixins.json @@ -1,16 +1,18 @@ { - "package": "net.caffeinemc.mods.sodium.mixin.fabric", - "required": true, - "compatibilityLevel": "JAVA_17", - "refmap": "sodium-fabric.refmap.json", - "injectors": { - "defaultRequire": 1 + "package" : "net.caffeinemc.mods.sodium.mixin.fabric", + "required" : true, + "compatibilityLevel" : "JAVA_17", + "refmap" : "sodium-fabric.refmap.json", + "injectors" : { + "defaultRequire" : 1 }, - "overwrites": { - "conformVisibility": true + "overwrites" : { + "conformVisibility" : true }, - "client": [ + "client" : [ + "core.WindowMixin", "core.model.quad.BakedQuadMixin", + "features.gui.hooks.settings.OptionsScreenMixin", "features.model.MultiPartBakedModelMixin", "features.model.WeightedBakedModelMixin", "features.render.model.block.ModelBlockRendererMixin" diff --git a/neoforge/src/main/java/net/caffeinemc/mods/sodium/neoforge/mixin/core/render/world/LevelRendererMixin.java b/neoforge/src/main/java/net/caffeinemc/mods/sodium/neoforge/mixin/core/render/world/LevelRendererMixin.java new file mode 100644 index 0000000000..decc722f0a --- /dev/null +++ b/neoforge/src/main/java/net/caffeinemc/mods/sodium/neoforge/mixin/core/render/world/LevelRendererMixin.java @@ -0,0 +1,21 @@ +package net.caffeinemc.mods.sodium.neoforge.mixin.core.render.world; + +import net.caffeinemc.mods.sodium.client.render.SodiumWorldRenderer; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.world.level.block.entity.BlockEntity; +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; + +import java.util.function.Consumer; + +@Mixin(LevelRenderer.class) +public class LevelRendererMixin { + @Inject(method = "iterateVisibleBlockEntities", at = @At("HEAD"), cancellable = true) + public void replaceBlockEntityIteration(Consumer blockEntityConsumer, CallbackInfo ci) { + ci.cancel(); + + SodiumWorldRenderer.instance().iterateVisibleBlockEntities(blockEntityConsumer); + } +} diff --git a/neoforge/src/main/java/net/caffeinemc/mods/sodium/neoforge/mixin/features/gui/hooks/settings/OptionsScreenMixin.java b/neoforge/src/main/java/net/caffeinemc/mods/sodium/neoforge/mixin/features/gui/hooks/settings/OptionsScreenMixin.java new file mode 100644 index 0000000000..d7fe0282f3 --- /dev/null +++ b/neoforge/src/main/java/net/caffeinemc/mods/sodium/neoforge/mixin/features/gui/hooks/settings/OptionsScreenMixin.java @@ -0,0 +1,24 @@ +package net.caffeinemc.mods.sodium.neoforge.mixin.features.gui.hooks.settings; + +import net.caffeinemc.mods.sodium.client.gui.SodiumOptionsGUI; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.gui.screens.options.OptionsScreen; +import net.minecraft.network.chat.Component; +import org.spongepowered.asm.mixin.Dynamic; +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; + +@Mixin(OptionsScreen.class) +public class OptionsScreenMixin extends Screen { + protected OptionsScreenMixin(Component title) { + super(title); + } + + @Dynamic + @Inject(method = "lambda$init$2", at = @At("HEAD"), cancellable = true) + private void open(CallbackInfoReturnable ci) { + ci.setReturnValue(SodiumOptionsGUI.createScreen(this)); + } +} diff --git a/neoforge/src/main/java/net/caffeinemc/mods/sodium/neoforge/mixin/features/options/render_layers/ItemBlockRenderTypesMixin.java b/neoforge/src/main/java/net/caffeinemc/mods/sodium/neoforge/mixin/features/options/render_layers/ItemBlockRenderTypesMixin.java new file mode 100644 index 0000000000..9c7b95e881 --- /dev/null +++ b/neoforge/src/main/java/net/caffeinemc/mods/sodium/neoforge/mixin/features/options/render_layers/ItemBlockRenderTypesMixin.java @@ -0,0 +1,30 @@ +package net.caffeinemc.mods.sodium.neoforge.mixin.features.options.render_layers; + +import net.caffeinemc.mods.sodium.client.SodiumClientMod; +import net.minecraft.client.GraphicsStatus; +import net.minecraft.client.renderer.ItemBlockRenderTypes; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(ItemBlockRenderTypes.class) +public class ItemBlockRenderTypesMixin { + @Unique + private static boolean leavesFancy; + + // getRenderLayers is a NeoForge only function required for the leaves to properly work. + @Redirect( + method = { "getRenderLayers" }, + at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/ItemBlockRenderTypes;renderCutout:Z")) + private static boolean redirectLeavesShouldBeFancy() { + return leavesFancy; + } + + @Inject(method = "setFancy", at = @At("RETURN")) + private static void onSetFancyGraphicsOrBetter(boolean fancyGraphicsOrBetter, CallbackInfo ci) { + leavesFancy = SodiumClientMod.options().quality.leavesQuality.isFancy(fancyGraphicsOrBetter ? GraphicsStatus.FANCY : GraphicsStatus.FAST); + } +} diff --git a/neoforge/src/main/java/net/caffeinemc/mods/sodium/neoforge/mixin/workarounds/context_creation/WindowMixin.java b/neoforge/src/main/java/net/caffeinemc/mods/sodium/neoforge/mixin/workarounds/context_creation/WindowMixin.java new file mode 100644 index 0000000000..9dbc172108 --- /dev/null +++ b/neoforge/src/main/java/net/caffeinemc/mods/sodium/neoforge/mixin/workarounds/context_creation/WindowMixin.java @@ -0,0 +1,34 @@ +package net.caffeinemc.mods.sodium.neoforge.mixin.workarounds.context_creation; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.mojang.blaze3d.platform.Window; +import net.caffeinemc.mods.sodium.client.compatibility.workarounds.Workarounds; +import net.caffeinemc.mods.sodium.client.compatibility.workarounds.nvidia.NvidiaWorkarounds; +import net.caffeinemc.mods.sodium.client.services.PlatformRuntimeInformation; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import java.util.function.IntSupplier; +import java.util.function.LongSupplier; +import java.util.function.Supplier; + +@Mixin(Window.class) +public class WindowMixin { + @WrapOperation(method = "", at = @At(value = "INVOKE", target = "Lnet/neoforged/fml/loading/ImmediateWindowHandler;setupMinecraftWindow(Ljava/util/function/IntSupplier;Ljava/util/function/IntSupplier;Ljava/util/function/Supplier;Ljava/util/function/LongSupplier;)J"), remap = false) + private long wrapGlfwCreateWindowForge(final IntSupplier width, final IntSupplier height, final Supplier title, final LongSupplier monitor, Operation op) { + final boolean applyNvidiaWorkarounds = Workarounds.isWorkaroundEnabled(Workarounds.Reference.NVIDIA_THREADED_OPTIMIZATIONS); + + if (applyNvidiaWorkarounds && !PlatformRuntimeInformation.getInstance().platformHasEarlyLoadingScreen()) { + NvidiaWorkarounds.install(); + } + + try { + return op.call(width, height, title, monitor); + } finally { + if (applyNvidiaWorkarounds) { + NvidiaWorkarounds.uninstall(); + } + } + } +} diff --git a/neoforge/src/main/resources/sodium-forge.mixins.json b/neoforge/src/main/resources/sodium-forge.mixins.json index b1e8217a29..e826589e89 100644 --- a/neoforge/src/main/resources/sodium-forge.mixins.json +++ b/neoforge/src/main/resources/sodium-forge.mixins.json @@ -11,9 +11,13 @@ }, "client" : [ "core.model.quad.BakedQuadMixin", + "core.render.world.LevelRendererMixin", + "features.gui.hooks.settings.OptionsScreenMixin", "features.model.MultiPartBakedModelMixin", "features.model.WeightedBakedModelMixin", + "features.options.render_layers.ItemBlockRenderTypesMixin", "features.render.model.block.ModelBlockRendererMixin", + "workarounds.context_creation.WindowMixin", "AbstractBlockRenderContextMixin", "AuxiliaryLightManagerMixin", "ChunkRenderTypeSetAccessor",