diff --git a/src/main/java/net/silentclient/client/Client.java b/src/main/java/net/silentclient/client/Client.java index 1d0a4d1..87ab869 100644 --- a/src/main/java/net/silentclient/client/Client.java +++ b/src/main/java/net/silentclient/client/Client.java @@ -22,6 +22,7 @@ import net.silentclient.client.gui.modmenu.ModMenu; import net.silentclient.client.gui.silentmainmenu.MainMenuConcept; import net.silentclient.client.gui.util.BackgroundPanorama; import net.silentclient.client.keybinds.KeyBindManager; +import net.silentclient.client.mixin.SilentClientTweaker; import net.silentclient.client.mixin.accessors.MinecraftAccessor; import net.silentclient.client.mods.ModInstances; import net.silentclient.client.mods.SettingsManager; @@ -156,6 +157,10 @@ public class Client { } logger.info("-------------------------------------------------"); memoryDebug("CLIENT_PRE_INIT"); + if(SilentClientTweaker.hasOptifine) { + logger.info("INITIALISING > optifine-patch"); + OptifinePatch.init(); + } logger.info("INITIALISING > gson-builder"); this.gson = (new GsonBuilder()).registerTypeAdapterFactory(new EnumAdapterFactory()).setPrettyPrinting() .enableComplexMapKeySerialization().create(); @@ -334,6 +339,10 @@ 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/utils/OptifinePatch.java b/src/main/java/net/silentclient/client/utils/OptifinePatch.java new file mode 100644 index 0000000..c9e8e02 --- /dev/null +++ b/src/main/java/net/silentclient/client/utils/OptifinePatch.java @@ -0,0 +1,34 @@ +package net.silentclient.client.utils; + +import net.minecraft.client.Minecraft; +import net.silentclient.client.Client; + +import java.io.File; +import java.io.FileOutputStream; + +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 void init() { + try { + if(optifineConfig.exists()) { + optifineConfig.renameTo(optifineConfigOriginal); + } + optifineConfig.createNewFile(); + FileOutputStream outputStream = new FileOutputStream(optifineConfig); + String str = "ofFastRender:true"; + byte[] strToBytes = str.getBytes(); + outputStream.write(strToBytes); + + outputStream.close(); + } catch (Exception err) { + Client.logger.catching(err); + } + } + + public static void start() { + optifineConfig.delete(); + optifineConfigOriginal.renameTo(optifineConfig); + } +}