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

@ -1,12 +1,11 @@
package net.silentclient.client.mods.render; package net.silentclient.client.mods.render;
import java.lang.reflect.Field;
import net.minecraft.client.settings.GameSettings; import net.minecraft.client.settings.GameSettings;
import net.silentclient.client.Client;
import net.silentclient.client.mods.Mod; import net.silentclient.client.mods.Mod;
import net.silentclient.client.mods.ModCategory; 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 { public class NewMotionBlurMod extends Mod {
private Field cachedFastRender; private Field cachedFastRender;
@ -37,4 +36,12 @@ public class NewMotionBlurMod extends Mod {
public boolean isForceDisabled() { public boolean isForceDisabled() {
return isFastRenderEnabled(); 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 net.silentclient.client.Client;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileInputStream;
public class OptifinePatch { public class OptifinePatch {
public static final File optifineConfig = new File(Minecraft.getMinecraft().mcDataDir, "optionsof.txt"); 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() { public static void init() {
try { try {
if(optifineConfig.exists()) { if(optifineConfig.exists()) {
optifineConfig.renameTo(optifineConfigOriginal); String ofConfig = FileUtils.readInputStream(new FileInputStream(optifineConfig));
}
optifineConfig.createNewFile();
FileOutputStream outputStream = new FileOutputStream(optifineConfig);
String str = "ofFastRender:false";
byte[] strToBytes = str.getBytes();
outputStream.write(strToBytes);
outputStream.close(); if(ofConfig.contains("ofFastRender:true")) {
fastRenderEnabled = true;
}
} else {
fastRenderEnabled = true;
}
} catch (Exception err) { } catch (Exception err) {
Client.logger.catching(err); Client.logger.catching(err);
} }
} }
public static void start() { public static boolean needPatch() {
optifineConfig.delete(); return fastRenderEnabled && !fastRenderPatched;
optifineConfigOriginal.renameTo(optifineConfig); }
Minecraft.getMinecraft().gameSettings.loadOptions();
public static void patch() {
Minecraft.getMinecraft().toggleFullscreen();
Minecraft.getMinecraft().toggleFullscreen();
fastRenderPatched = true;
} }
} }