From d8da688176b558cf3eba45b434cf88945df571cc Mon Sep 17 00:00:00 2001 From: Desoroxxx Date: Sun, 16 Jul 2023 00:21:40 +0200 Subject: [PATCH] Fixed OptiNotFine --- src/main/java/com/paneedah/mwc/MWC.java | 3 --- src/main/java/com/paneedah/mwc/proxies/ClientProxy.java | 6 ++++++ src/main/java/com/paneedah/mwc/utils/OptiNotFine.java | 7 ++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/paneedah/mwc/MWC.java b/src/main/java/com/paneedah/mwc/MWC.java index f569ac66f..4bfe84c14 100644 --- a/src/main/java/com/paneedah/mwc/MWC.java +++ b/src/main/java/com/paneedah/mwc/MWC.java @@ -61,9 +61,6 @@ public void preInit(FMLPreInitializationEvent preInitializationEvent) { @EventHandler public void init(FMLInitializationEvent initializationEvent) { - if (initializationEvent.getSide() == Side.CLIENT && OptiNotFine.isOptiFineInstalled()) - MinecraftForge.EVENT_BUS.register(OptiNotFine.class); - MWCRecipes.register(); commonProxy.init(this); } diff --git a/src/main/java/com/paneedah/mwc/proxies/ClientProxy.java b/src/main/java/com/paneedah/mwc/proxies/ClientProxy.java index 1312f5c52..6386ebc59 100644 --- a/src/main/java/com/paneedah/mwc/proxies/ClientProxy.java +++ b/src/main/java/com/paneedah/mwc/proxies/ClientProxy.java @@ -5,6 +5,7 @@ import com.paneedah.mwc.init.MWCItems; import com.paneedah.mwc.models.Workbench; import com.paneedah.mwc.utils.ModReference; +import com.paneedah.mwc.utils.OptiNotFine; import com.paneedah.mwc.wearables.Armors; import com.paneedah.weaponlib.crafting.ammopress.TESRAmmoPress; import com.paneedah.weaponlib.crafting.ammopress.TileEntityAmmoPress; @@ -21,8 +22,10 @@ import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.ForgeModContainer; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.relauncher.Side; public class ClientProxy extends CommonProxy { @@ -110,6 +113,9 @@ public void init(final MWC mod) { if (ForgeModContainer.allowEmissiveItems) ForgeModContainer.allowEmissiveItems = false; + + if (OptiNotFine.isOptiFineInstalled()) + MinecraftForge.EVENT_BUS.register(OptiNotFine.class); } @Override diff --git a/src/main/java/com/paneedah/mwc/utils/OptiNotFine.java b/src/main/java/com/paneedah/mwc/utils/OptiNotFine.java index b15274544..e58598849 100644 --- a/src/main/java/com/paneedah/mwc/utils/OptiNotFine.java +++ b/src/main/java/com/paneedah/mwc/utils/OptiNotFine.java @@ -7,6 +7,7 @@ import java.lang.reflect.Field; +import static com.paneedah.mwc.proxies.ClientProxy.mc; import static com.paneedah.mwc.utils.ModReference.RED_LOG; /** @@ -68,16 +69,16 @@ public static boolean shadersEnabled() { } /** - * Disable OptiFine fast render. + * Disable OptiFine fast renderer. */ private static void disableFastRender() { try { if (fastRenderField == null) fastRenderField = Class.forName("net.minecraft.client.settings.GameSettings").getDeclaredField("ofFastRender"); - fastRenderField.set(null, false); + fastRenderField.set(mc.gameSettings, false); } catch (IllegalAccessException | ClassNotFoundException | NoSuchFieldException exception) { - RED_LOG.printFramedError("OptiNotFine", "Could not get OptiFine shaders status.", "If shaders are enabled things might break", exception.getMessage()); + RED_LOG.printFramedError("OptiNotFine", "Could not disable OptiFine fast renderer", "Things will break", exception.getMessage()); } }