diff --git a/app_pojavlauncher/src/main/assets/components/OptiInst.jar b/app_pojavlauncher/src/main/assets/components/OptiInst.jar new file mode 100644 index 000000000..94b951bc7 Binary files /dev/null and b/app_pojavlauncher/src/main/assets/components/OptiInst.jar differ diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/JavaGUILauncherActivity.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/JavaGUILauncherActivity.java index 9c1bb7c93..45bd32faa 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/JavaGUILauncherActivity.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/JavaGUILauncherActivity.java @@ -172,6 +172,9 @@ public class JavaGUILauncherActivity extends LoggableActivity { } else if (InstallerDetector.isFabric(installer)) { appendlnToLog("Detected Fabric Installer!"); return new FabricInstaller(installer).install(this); + }else if (InstallerDetector.isOptiFine(installer)) { + appendlnToLog("Detected OptiFine Installer!"); + return new LegacyOptifineInstaller(installer).install(this); } else { appendlnToLog("No mod detected. Starting JVM"); isLogAllow = false; diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/PojavLoginActivity.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/PojavLoginActivity.java index 5742501b5..712aba67f 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/PojavLoginActivity.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/PojavLoginActivity.java @@ -332,6 +332,8 @@ public class PojavLoginActivity extends BaseActivity Tools.copyAssetFile(this, "components/ForgeInstallerHeadless/forge-installer-headless-1.0.1.jar", Tools.DIR_GAME_NEW + "/config", "forge-installer-headless.jar", true); + Tools.copyAssetFile(this, "components/OptiInst.jar", + Tools.DIR_GAME_NEW + "/config", "OptiInst.jar", true); Tools.copyAssetFile(this, "components/security/pro-grade.jar", Tools.DIR_DATA, true); Tools.copyAssetFile(this, "components/security/java_sandbox.policy", Tools.DIR_DATA, true); Tools.copyAssetFile(this, "options.txt", Tools.DIR_GAME_NEW, false); diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/installers/InstallerDetector.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/installers/InstallerDetector.java index 98af7ac90..154da56fb 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/installers/InstallerDetector.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/installers/InstallerDetector.java @@ -1,6 +1,9 @@ package net.kdt.pojavlaunch.installers; import java.io.*; +import java.util.Enumeration; +import java.util.zip.ZipEntry; + import com.google.gson.*; import net.kdt.pojavlaunch.value.*; @@ -9,7 +12,10 @@ public class InstallerDetector public static boolean isFabric(BaseInstaller installer) { return installer.mJarFile.getEntry("net/fabricmc/installer/Main.class") != null; } - + public static boolean isOptiFine(BaseInstaller installer) { + Enumeration e = installer.mJarFile.entries(); + return installer.mJarFile.getEntry("optifine/Installer.class") != null; + } // Forge Legacy: for 1.12.1 and below public static boolean isForgeLegacy(BaseInstaller installer) throws IOException, JsonSyntaxException { ForgeInstallProfile profile = LegacyForgeInstaller.readInstallProfile(installer); diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/installers/LegacyOptifineInstaller.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/installers/LegacyOptifineInstaller.java index 99b316bd2..ced61373d 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/installers/LegacyOptifineInstaller.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/installers/LegacyOptifineInstaller.java @@ -17,7 +17,9 @@ public class LegacyOptifineInstaller extends BaseInstaller { @Override public int install(JavaGUILauncherActivity ctx) throws IOException { - - return 0; + mJarFile.close(); + ctx.appendlnToLog("Launching JVM"); + return ctx.launchJavaRuntime(null, + "-jar "+Tools.DIR_GAME_NEW+"/config/OptiInst.jar " + mFile.getAbsolutePath() +" ."); } }