From 4f57cae5ef6ffa9aa198be06ac843df9ca1d6261 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Sun, 8 Sep 2024 21:28:01 +0100 Subject: Revert "Merge pull request #1 from TheKodeToad/fix-new-forge-installer" This reverts commit c2a65dd98f5e405bc7997b1fee62c89a0414fa67, reversing changes made to 271bf51f809de6f2f47a1129b86df3a1594e1d6b. --- build.gradle | 2 +- .../forgewrapper/installer/util/InstallerV1.java | 31 +++++++++++----------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/build.gradle b/build.gradle index 9c3464b364..aa71402bd3 100644 --- a/build.gradle +++ b/build.gradle @@ -35,7 +35,7 @@ repositories { dependencies { compileOnly "com.google.code.gson:gson:2.8.7" compileOnly "cpw.mods:modlauncher:8.0.9" - compileOnly "net.minecraftforge:installer:2.2.7" + compileOnly "net.minecraftforge:installer:2.1.9" compileOnly "net.sf.jopt-simple:jopt-simple:5.0.4" provided project(":common") diff --git a/src/main/java/io/github/zekerzhayard/forgewrapper/installer/util/InstallerV1.java b/src/main/java/io/github/zekerzhayard/forgewrapper/installer/util/InstallerV1.java index c9ceeaf45c..014a6240ea 100644 --- a/src/main/java/io/github/zekerzhayard/forgewrapper/installer/util/InstallerV1.java +++ b/src/main/java/io/github/zekerzhayard/forgewrapper/installer/util/InstallerV1.java @@ -1,9 +1,9 @@ package io.github.zekerzhayard.forgewrapper.installer.util; import java.io.File; -import java.lang.reflect.Method; +import java.util.function.Predicate; -import net.minecraftforge.installer.actions.PostProcessors; +import net.minecraftforge.installer.actions.ClientInstall; import net.minecraftforge.installer.actions.ProgressCallback; import net.minecraftforge.installer.json.Install; import net.minecraftforge.installer.json.InstallV1; @@ -16,22 +16,23 @@ public class InstallerV1 extends AbstractInstaller { } @Override - public boolean runClientInstall(Install profile, ProgressCallback monitor, File libraryDir, File minecraftJar, - File installerJar) { - PostProcessors processors = new PostProcessors( - profile instanceof InstallV1 ? (InstallV1) profile : new InstallV1(profile), true, monitor); + public boolean runClientInstall(Install profile, ProgressCallback monitor, File libraryDir, File minecraftJar, File installerJar) { + return new ClientInstall4MultiMC(profile, monitor, libraryDir, minecraftJar).run(null, input -> true, installerJar); + } - try { - Method method = processors.getClass().getMethod("process", File.class, File.class, File.class, File.class); - Object result = method.invoke(processors, libraryDir, minecraftJar, libraryDir.getParentFile(), - installerJar); + public static class ClientInstall4MultiMC extends ClientInstall { + protected File libraryDir; + protected File minecraftJar; - if (method.getReturnType() == boolean.class) - return (boolean) result; + public ClientInstall4MultiMC(Install profile, ProgressCallback monitor, File libraryDir, File minecraftJar) { + super(profile instanceof InstallV1 ? (InstallV1) profile : new InstallV1(profile), monitor); + this.libraryDir = libraryDir; + this.minecraftJar = minecraftJar; + } - return result != null; - } catch (ReflectiveOperationException e) { - throw new RuntimeException(e); + @Override + public boolean run(File target, Predicate optionals, File installer) { + return this.processors.process(this.libraryDir, this.minecraftJar, this.libraryDir.getParentFile(), installer); } } } -- cgit 0.0.5-2-1-g0f52