Optifine Patch

This commit is contained in:
kirillsaint 2023-08-31 14:33:18 +06:00
parent 7251b4f0c1
commit 05fb9d60bf
2 changed files with 43 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import net.silentclient.client.gui.modmenu.ModMenu;
import net.silentclient.client.gui.silentmainmenu.MainMenuConcept; import net.silentclient.client.gui.silentmainmenu.MainMenuConcept;
import net.silentclient.client.gui.util.BackgroundPanorama; import net.silentclient.client.gui.util.BackgroundPanorama;
import net.silentclient.client.keybinds.KeyBindManager; import net.silentclient.client.keybinds.KeyBindManager;
import net.silentclient.client.mixin.SilentClientTweaker;
import net.silentclient.client.mixin.accessors.MinecraftAccessor; import net.silentclient.client.mixin.accessors.MinecraftAccessor;
import net.silentclient.client.mods.ModInstances; import net.silentclient.client.mods.ModInstances;
import net.silentclient.client.mods.SettingsManager; import net.silentclient.client.mods.SettingsManager;
@ -156,6 +157,10 @@ public class Client {
} }
logger.info("-------------------------------------------------"); logger.info("-------------------------------------------------");
memoryDebug("CLIENT_PRE_INIT"); memoryDebug("CLIENT_PRE_INIT");
if(SilentClientTweaker.hasOptifine) {
logger.info("INITIALISING > optifine-patch");
OptifinePatch.init();
}
logger.info("INITIALISING > gson-builder"); logger.info("INITIALISING > gson-builder");
this.gson = (new GsonBuilder()).registerTypeAdapterFactory(new EnumAdapterFactory()).setPrettyPrinting() this.gson = (new GsonBuilder()).registerTypeAdapterFactory(new EnumAdapterFactory()).setPrettyPrinting()
.enableComplexMapKeySerialization().create(); .enableComplexMapKeySerialization().create();
@ -334,6 +339,10 @@ public class Client {
logger.info("STARTING > ERROR: " + err.getMessage()); logger.info("STARTING > ERROR: " + err.getMessage());
throw err; throw err;
} }
if(SilentClientTweaker.hasOptifine) {
logger.info("STARTING > optifine-patch");
OptifinePatch.start();
}
logger.info("-------------------------------------------------"); logger.info("-------------------------------------------------");
memoryDebug("CLIENT_POST_INIT"); memoryDebug("CLIENT_POST_INIT");
} }

View File

@ -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);
}
}