From 1246d26425a420b30978f6beacdccd29d765527c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=91=E5=AB=96233?= Date: Tue, 6 Feb 2024 12:57:40 +0800 Subject: [PATCH] Fix neoforge install MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 黑嫖233 --- src/launcher.ts | 2 +- src/loaders/fabric.ts | 4 ++++ src/loaders/fabriclike/fabriclike.ts | 3 ++- src/loaders/forge.ts | 8 +++++++- src/loaders/forgelike/forgelike.ts | 15 +++++++++------ src/loaders/neoforge.ts | 11 ++++++++++- src/loaders/quilt/quilt.ts | 5 +++++ 7 files changed, 38 insertions(+), 10 deletions(-) diff --git a/src/launcher.ts b/src/launcher.ts index 8bbb360..aefff79 100644 --- a/src/launcher.ts +++ b/src/launcher.ts @@ -125,7 +125,7 @@ export class Launcher { this.loaders.set("fabric", new FabricLoader(this)); this.loaders.set("quilt", new QuiltLoader(this)); this.loaders.set("forge", new ForgeLoader(this)); - this.loaders.set("forge", new NeoForgeLoader(this)); + this.loaders.set("neoforge", new NeoForgeLoader(this)); this.accountTypes.set("microsoft", (data)=>new MicrosoftAccount(data, this)); this.accountTypes.set("offline", (data)=>new OfflineAccount(data, this)); this.accountTypes.set("authlib_injector", (data)=>new AuthlibInjectorAccount(data, this)); diff --git a/src/loaders/fabric.ts b/src/loaders/fabric.ts index 1be66bc..3a14132 100644 --- a/src/loaders/fabric.ts +++ b/src/loaders/fabric.ts @@ -9,6 +9,8 @@ import { ModLoadingIssue } from "./loader.js"; export class FabricLoader extends FabricLikeLoader { metaURL = "https://meta.fabricmc.net/v2"; loaderMaven = "https://maven.fabricmc.net/"; + name = "fabric"; + findInVersion(MCVersion: MCVersion): string | undefined { let ret: string | undefined; MCVersion.libraries.forEach(i=>{ @@ -18,6 +20,7 @@ export class FabricLoader extends FabricLikeLoader[], mc: string, loader: string): ModLoadingIssue[] { const modIdVersions: Record = { minecraft: normalizeVersion(mc), @@ -59,6 +62,7 @@ export class FabricLoader extends FabricLikeLoader, launcher: Launcher): ModLoadingIssue[] { const issues: ModLoadingIssue[] = []; for (const id in mod.depends) { diff --git a/src/loaders/fabriclike/fabriclike.ts b/src/loaders/fabriclike/fabriclike.ts index 6097c3a..ab29b6f 100644 --- a/src/loaders/fabriclike/fabriclike.ts +++ b/src/loaders/fabriclike/fabriclike.ts @@ -18,6 +18,7 @@ import { VersionPredicateParser } from "./version/VersionPredicateParser.js"; export abstract class FabricLikeLoader implements Loader { abstract loaderMaven: string; abstract metaURL: string; + abstract name: string; intermediaryMaven = "https://maven.fabricmc.net/"; protected readonly launcher: Launcher; constructor (launcher: Launcher) { @@ -51,7 +52,7 @@ export abstract class FabricLikeLoader imple result.push(...await this.findModInfos(filename)); } } - const info = new ModInfo("fabric", json, this.launcher); + const info = new ModInfo(this.name, json, this.launcher); info.data = json; result.push(info); return result; diff --git a/src/loaders/forge.ts b/src/loaders/forge.ts index d0d8693..fbe36f9 100644 --- a/src/loaders/forge.ts +++ b/src/loaders/forge.ts @@ -2,8 +2,14 @@ import { MCVersion } from "../schemas.js"; import { ForgeLikeLoader } from "./forgelike/forgelike.js"; export class ForgeLoader extends ForgeLikeLoader { - protected mavenArtifactURL = "https://maven.minecraftforge.net/net/minecraftforge/forge"; + protected mavenArtifactURL = "https://maven.minecraftforge.net/net/minecraftforge"; protected supportsOld = false; + name = "forge"; + + getArchiveBaseName(MCVersion: string): string { + return "forge"; + } + findInVersion(MCVersion: MCVersion): string | undefined { for (const i of MCVersion.libraries) { if(i.name.includes(":fmlloader:") || i.name.includes(":forge:")){ diff --git a/src/loaders/forgelike/forgelike.ts b/src/loaders/forgelike/forgelike.ts index 85b5a9b..4a15f07 100644 --- a/src/loaders/forgelike/forgelike.ts +++ b/src/loaders/forgelike/forgelike.ts @@ -27,11 +27,13 @@ export abstract class ForgeLikeLoader implements Loader { if(MCVersion.extras.version === "Unknown") { @@ -43,7 +45,7 @@ export abstract class ForgeLikeLoader implements Loader v.startsWith(`${MCVersion.extras.version}-`)); @@ -54,8 +56,9 @@ export abstract class ForgeLikeLoader implements Loader { if (a === "SIDE") return "client"; if (a === "MINECRAFT_JAR") return `${MCVersion.versionRoot}/${MCVersion.name}.jar`; - if (a === "BINPATCH") return `${tmpdir()}/${this.launcher.name}_forge_installer/data/client.lzma`; + if (a === "BINPATCH") return `${tmpdir()}/${this.launcher.name}_forgelike_installer/data/client.lzma`; return metadata.data[a].client; }).replaceAll(/\[(.+?)\]/g, (v, a) => `${this.launcher.rootPath}/libraries/${expandMavenId(a)}`); } @@ -157,13 +160,13 @@ export abstract class ForgeLikeLoader implements Loader{ @@ -23,6 +25,7 @@ export class QuiltLoader extends FabricLikeLoader[]> { const zip = new StreamZip.async({ file: path @@ -51,6 +54,7 @@ export class QuiltLoader extends FabricLikeLoader[], mc: string, loader: string): ModLoadingIssue[] { const modIdVersions: Record = { minecraft: normalizeVersion(mc), @@ -216,6 +220,7 @@ function processDeps(deps?: DependencyObject[] | DependencyObject | string): Dep } return ret; } + function formatUnless(unlesses: DependencyObject[], launcher: Launcher): string { return unlesses.map( (v) => `${v.id} ${launcher.i18n("misc.version")} ${formatDepVersion(v.versions ?? "*", launcher)}`