Skip to content

Commit

Permalink
Merge pull request #1 from TheKodeToad/fix-new-forge-installer
Browse files Browse the repository at this point in the history
Fix for update to Forge installer
  • Loading branch information
TheKodeToad authored Feb 29, 2024
2 parents 271bf51 + b8a6172 commit c2a65dd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ repositories {
dependencies {
compileOnly "com.google.code.gson:gson:2.8.7"
compileOnly "cpw.mods:modlauncher:8.0.9"
compileOnly "net.minecraftforge:installer:2.1.9"
compileOnly "net.minecraftforge:installer:2.2.7"
compileOnly "net.sf.jopt-simple:jopt-simple:5.0.4"

provided project(":common")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.github.zekerzhayard.forgewrapper.installer.util;

import java.io.File;
import java.util.function.Predicate;
import java.lang.reflect.Method;

import net.minecraftforge.installer.actions.ClientInstall;
import net.minecraftforge.installer.actions.PostProcessors;
import net.minecraftforge.installer.actions.ProgressCallback;
import net.minecraftforge.installer.json.Install;
import net.minecraftforge.installer.json.InstallV1;
Expand All @@ -16,23 +16,22 @@ public Install loadInstallProfile() {
}

@Override
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);
}
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 static class ClientInstall4MultiMC extends ClientInstall {
protected File libraryDir;
protected File minecraftJar;
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 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;
}
if (method.getReturnType() == boolean.class)
return (boolean) result;

@Override
public boolean run(File target, Predicate<String> optionals, File installer) {
return this.processors.process(this.libraryDir, this.minecraftJar, this.libraryDir.getParentFile(), installer);
return result != null;
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
}
}

0 comments on commit c2a65dd

Please sign in to comment.