diff --git a/src/main/java/net/silentclient/client/Client.java b/src/main/java/net/silentclient/client/Client.java index 87ab869..323bc90 100644 --- a/src/main/java/net/silentclient/client/Client.java +++ b/src/main/java/net/silentclient/client/Client.java @@ -339,10 +339,6 @@ public class Client { logger.info("STARTING > ERROR: " + err.getMessage()); throw err; } - if(SilentClientTweaker.hasOptifine) { - logger.info("STARTING > optifine-patch"); - OptifinePatch.start(); - } logger.info("-------------------------------------------------"); memoryDebug("CLIENT_POST_INIT"); } diff --git a/src/main/java/net/silentclient/client/mods/render/NewMotionBlurMod.java b/src/main/java/net/silentclient/client/mods/render/NewMotionBlurMod.java index 319f2f3..5471894 100644 --- a/src/main/java/net/silentclient/client/mods/render/NewMotionBlurMod.java +++ b/src/main/java/net/silentclient/client/mods/render/NewMotionBlurMod.java @@ -1,12 +1,11 @@ package net.silentclient.client.mods.render; -import java.lang.reflect.Field; - import net.minecraft.client.settings.GameSettings; -import net.silentclient.client.Client; import net.silentclient.client.mods.Mod; import net.silentclient.client.mods.ModCategory; -import net.silentclient.client.utils.NotificationUtils; +import net.silentclient.client.utils.OptifinePatch; + +import java.lang.reflect.Field; public class NewMotionBlurMod extends Mod { private Field cachedFastRender; @@ -37,4 +36,12 @@ public class NewMotionBlurMod extends Mod { public boolean isForceDisabled() { return isFastRenderEnabled(); } + + @Override + public void onEnable() { + super.onEnable(); + if(!isFastRenderEnabled() && OptifinePatch.needPatch()) { + OptifinePatch.patch(); + } + } } diff --git a/src/main/java/net/silentclient/client/utils/OptifinePatch.java b/src/main/java/net/silentclient/client/utils/OptifinePatch.java index 1aaf412..0590f2d 100644 --- a/src/main/java/net/silentclient/client/utils/OptifinePatch.java +++ b/src/main/java/net/silentclient/client/utils/OptifinePatch.java @@ -4,32 +4,36 @@ import net.minecraft.client.Minecraft; import net.silentclient.client.Client; import java.io.File; -import java.io.FileOutputStream; +import java.io.FileInputStream; public class OptifinePatch { public static final File optifineConfig = new File(Minecraft.getMinecraft().mcDataDir, "optionsof.txt"); - public static final File optifineConfigOriginal = new File(Minecraft.getMinecraft().mcDataDir, "optionsof.txt.original"); + public static boolean fastRenderEnabled = false; + public static boolean fastRenderPatched = false; public static void init() { try { if(optifineConfig.exists()) { - optifineConfig.renameTo(optifineConfigOriginal); - } - optifineConfig.createNewFile(); - FileOutputStream outputStream = new FileOutputStream(optifineConfig); - String str = "ofFastRender:false"; - byte[] strToBytes = str.getBytes(); - outputStream.write(strToBytes); + String ofConfig = FileUtils.readInputStream(new FileInputStream(optifineConfig)); - outputStream.close(); + if(ofConfig.contains("ofFastRender:true")) { + fastRenderEnabled = true; + } + } else { + fastRenderEnabled = true; + } } catch (Exception err) { Client.logger.catching(err); } } - public static void start() { - optifineConfig.delete(); - optifineConfigOriginal.renameTo(optifineConfig); - Minecraft.getMinecraft().gameSettings.loadOptions(); + public static boolean needPatch() { + return fastRenderEnabled && !fastRenderPatched; + } + + public static void patch() { + Minecraft.getMinecraft().toggleFullscreen(); + Minecraft.getMinecraft().toggleFullscreen(); + fastRenderPatched = true; } }