Fix: Cannot install modpacks with NeoForge for Minecraft 1.20.1. (#2708)
* Fix: Cannot install modpacks with NeoForge for Minecraft 1.20.1. * Add supports for MultiMC Modpack with NeoForge.
This commit is contained in:
@@ -26,6 +26,7 @@ import org.jackhuang.hmcl.util.Lang;
|
|||||||
import org.jackhuang.hmcl.util.StringUtils;
|
import org.jackhuang.hmcl.util.StringUtils;
|
||||||
import org.jackhuang.hmcl.util.gson.Validation;
|
import org.jackhuang.hmcl.util.gson.Validation;
|
||||||
import org.jackhuang.hmcl.util.io.HttpRequest;
|
import org.jackhuang.hmcl.util.io.HttpRequest;
|
||||||
|
import org.jackhuang.hmcl.util.versioning.VersionNumber;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -58,6 +59,15 @@ public final class NeoForgeBMCLVersionList extends VersionList<NeoForgeRemoteVer
|
|||||||
throw new UnsupportedOperationException("NeoForgeBMCLVersionList does not support loading the entire NeoForge remote version list.");
|
throw new UnsupportedOperationException("NeoForgeBMCLVersionList does not support loading the entire NeoForge remote version list.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<NeoForgeRemoteVersion> getVersion(String gameVersion, String remoteVersion) {
|
||||||
|
if (gameVersion.equals("1.20.1")) {
|
||||||
|
remoteVersion = NeoForgeRemoteVersion.fixInvalidVersion(remoteVersion);
|
||||||
|
remoteVersion = VersionNumber.compare(remoteVersion, "47.1.85") >= 0 ? "1.20.1-" + remoteVersion : remoteVersion;
|
||||||
|
}
|
||||||
|
return super.getVersion(gameVersion, remoteVersion);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<?> refreshAsync(String gameVersion) {
|
public CompletableFuture<?> refreshAsync(String gameVersion) {
|
||||||
return CompletableFuture.completedFuture((Void) null)
|
return CompletableFuture.completedFuture((Void) null)
|
||||||
@@ -87,12 +97,6 @@ public final class NeoForgeBMCLVersionList extends VersionList<NeoForgeRemoteVer
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<NeoForgeRemoteVersion> getVersion(String gameVersion, String remoteVersion) {
|
|
||||||
remoteVersion = StringUtils.substringAfter(remoteVersion, "-", remoteVersion);
|
|
||||||
return super.getVersion(gameVersion, remoteVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
private static final class NeoForgeVersion implements Validation {
|
private static final class NeoForgeVersion implements Validation {
|
||||||
private final String rawVersion;
|
private final String rawVersion;
|
||||||
@@ -108,18 +112,6 @@ public final class NeoForgeBMCLVersionList extends VersionList<NeoForgeRemoteVer
|
|||||||
this.mcVersion = mcVersion;
|
this.mcVersion = mcVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRawVersion() {
|
|
||||||
return this.rawVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getVersion() {
|
|
||||||
return this.version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMcVersion() {
|
|
||||||
return this.mcVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate() throws JsonParseException {
|
public void validate() throws JsonParseException {
|
||||||
if (this.rawVersion == null) {
|
if (this.rawVersion == null) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.jackhuang.hmcl.util.StringUtils;
|
|||||||
import org.jackhuang.hmcl.util.io.HttpRequest;
|
import org.jackhuang.hmcl.util.io.HttpRequest;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import static org.jackhuang.hmcl.util.Lang.wrap;
|
import static org.jackhuang.hmcl.util.Lang.wrap;
|
||||||
@@ -27,6 +28,17 @@ public final class NeoForgeOfficialVersionList extends VersionList<NeoForgeRemot
|
|||||||
|
|
||||||
private static final String META_URL = "https://maven.neoforged.net/api/maven/versions/releases/net/neoforged/neoforge";
|
private static final String META_URL = "https://maven.neoforged.net/api/maven/versions/releases/net/neoforged/neoforge";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<NeoForgeRemoteVersion> getVersion(String gameVersion, String remoteVersion) {
|
||||||
|
if (gameVersion.equals("1.20.1")) {
|
||||||
|
remoteVersion = NeoForgeRemoteVersion.fixInvalidVersion(remoteVersion);
|
||||||
|
if (!remoteVersion.equals("47.1.82")) {
|
||||||
|
remoteVersion = "1.20.1-" + remoteVersion;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.getVersion(gameVersion, remoteVersion);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<?> refreshAsync() {
|
public CompletableFuture<?> refreshAsync() {
|
||||||
return CompletableFuture.supplyAsync(wrap(() -> new OfficialAPIResult[]{
|
return CompletableFuture.supplyAsync(wrap(() -> new OfficialAPIResult[]{
|
||||||
|
|||||||
@@ -17,4 +17,16 @@ public class NeoForgeRemoteVersion extends RemoteVersion {
|
|||||||
public Task<Version> getInstallTask(DefaultDependencyManager dependencyManager, Version baseVersion) {
|
public Task<Version> getInstallTask(DefaultDependencyManager dependencyManager, Version baseVersion) {
|
||||||
return new NeoForgeInstallTask(dependencyManager, baseVersion, this);
|
return new NeoForgeInstallTask(dependencyManager, baseVersion, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String fixInvalidVersion(String version) {
|
||||||
|
if (version.startsWith("1.20.1-")) {
|
||||||
|
if (version.startsWith("forge-", "1.20.1-".length())) {
|
||||||
|
return version.substring("1.20.1-forge-".length());
|
||||||
|
} else {
|
||||||
|
return version.substring("1.20.1-".length());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,9 +77,8 @@ public class MultiMCModpackExportTask extends Task<Void> {
|
|||||||
components.add(new MultiMCManifest.MultiMCManifestComponent(true, false, "net.minecraft", gameVersion));
|
components.add(new MultiMCManifest.MultiMCManifestComponent(true, false, "net.minecraft", gameVersion));
|
||||||
analyzer.getVersion(FORGE).ifPresent(forgeVersion ->
|
analyzer.getVersion(FORGE).ifPresent(forgeVersion ->
|
||||||
components.add(new MultiMCManifest.MultiMCManifestComponent(false, false, "net.minecraftforge", forgeVersion)));
|
components.add(new MultiMCManifest.MultiMCManifestComponent(false, false, "net.minecraftforge", forgeVersion)));
|
||||||
// MultiMC hasn't supported NeoForge yet.
|
analyzer.getVersion(NEO_FORGE).ifPresent(neoForgeVersion ->
|
||||||
// analyzer.getVersion(NEO_FORGE).ifPresent(neoForgeVersion ->
|
components.add(new MultiMCManifest.MultiMCManifestComponent(false, false, "net.neoforged", neoForgeVersion)));
|
||||||
// components.add(new MultiMCManifest.MultiMCManifestComponent(false, false, "net.neoforged", neoForgeVersion)));
|
|
||||||
analyzer.getVersion(LITELOADER).ifPresent(liteLoaderVersion ->
|
analyzer.getVersion(LITELOADER).ifPresent(liteLoaderVersion ->
|
||||||
components.add(new MultiMCManifest.MultiMCManifestComponent(false, false, "com.mumfrey.liteloader", liteLoaderVersion)));
|
components.add(new MultiMCManifest.MultiMCManifestComponent(false, false, "com.mumfrey.liteloader", liteLoaderVersion)));
|
||||||
analyzer.getVersion(FABRIC).ifPresent(fabricVersion ->
|
analyzer.getVersion(FABRIC).ifPresent(fabricVersion ->
|
||||||
|
|||||||
@@ -78,12 +78,11 @@ public final class MultiMCModpackInstallTask extends Task<Void> {
|
|||||||
builder.version("forge", c.getVersion());
|
builder.version("forge", c.getVersion());
|
||||||
});
|
});
|
||||||
|
|
||||||
// MultiMC hasn't supported NeoForge yet.
|
Optional<MultiMCManifest.MultiMCManifestComponent> neoForge = manifest.getMmcPack().getComponents().stream().filter(e -> e.getUid().equals("net.neoforged")).findAny();
|
||||||
// Optional<MultiMCManifest.MultiMCManifestComponent> neoForge = manifest.getMmcPack().getComponents().stream().filter(e -> e.getUid().equals("net.neoforged")).findAny();
|
neoForge.ifPresent(c -> {
|
||||||
// neoForge.ifPresent(c -> {
|
if (c.getVersion() != null)
|
||||||
// if (c.getVersion() != null)
|
builder.version("neoforge", c.getVersion());
|
||||||
// builder.version("neoforge", c.getVersion());
|
});
|
||||||
// });
|
|
||||||
|
|
||||||
Optional<MultiMCManifest.MultiMCManifestComponent> liteLoader = manifest.getMmcPack().getComponents().stream().filter(e -> e.getUid().equals("com.mumfrey.liteloader")).findAny();
|
Optional<MultiMCManifest.MultiMCManifestComponent> liteLoader = manifest.getMmcPack().getComponents().stream().filter(e -> e.getUid().equals("com.mumfrey.liteloader")).findAny();
|
||||||
liteLoader.ifPresent(c -> {
|
liteLoader.ifPresent(c -> {
|
||||||
|
|||||||
Reference in New Issue
Block a user