This commit is contained in:
kirillsaint 2023-08-31 14:52:49 +06:00
parent da32a4806b
commit 5b3e721fc9
3 changed files with 29 additions and 22 deletions

View File

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

View File

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

View File

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