Skip to content

Commit

Permalink
Fixed OptiNotFine
Browse files Browse the repository at this point in the history
  • Loading branch information
Desoroxxx committed Jul 15, 2023
1 parent 18f58df commit d8da688
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 0 additions & 3 deletions src/main/java/com/paneedah/mwc/MWC.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/paneedah/mwc/proxies/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/paneedah/mwc/utils/OptiNotFine.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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());
}
}

Expand Down

0 comments on commit d8da688

Please sign in to comment.