-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(install): add ModLoader for legacy Forge versions
- Loading branch information
Showing
5 changed files
with
112 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import type { Container } from "@/main/container/spec"; | ||
import { paths } from "@/main/fs/paths"; | ||
import { dlx } from "@/main/net/dlx"; | ||
import type { Library } from "@/main/profile/version-profile"; | ||
import { unwrapESM } from "@/main/util/module"; | ||
import fs from "fs-extra"; | ||
import { nanoid } from "nanoid"; | ||
|
||
async function loadCompat() { | ||
return await unwrapESM(import("@/refs/legacy-forge-compat.json")); | ||
} | ||
|
||
async function shouldUseVenv(v: string): Promise<boolean> { | ||
return (await loadCompat()).venv.includes(v); | ||
} | ||
|
||
async function getModLoaderUrl(v: string): Promise<string> { | ||
return (await loadCompat() as any)["mod-loader"][v] ?? ""; | ||
} | ||
|
||
async function downloadModLoader(url: string): Promise<string> { | ||
console.debug(`Fetching ModLoader from ${url}`); | ||
const fp = paths.temp.to(`mod-loader-${nanoid()}.jar`); | ||
await dlx.getAll([{ url, path: fp }]); | ||
return fp; | ||
} | ||
|
||
async function getModLoaderDamtLibrary(): Promise<Library> { | ||
return (await loadCompat())["damt"]; | ||
} | ||
|
||
async function getModLoaderDamtArg(): Promise<string> { | ||
return (await loadCompat())["damt-arg"]; | ||
} | ||
|
||
async function patchProfile(container: Container, id: string) { | ||
console.debug(`Patching ${id} with DAMT...`); | ||
const prof = await fs.readJSON(container.profile(id)); | ||
prof.libraries.push(await getModLoaderDamtLibrary()); | ||
prof.minecraftArguments += (" " + await getModLoaderDamtArg()); | ||
await fs.writeJSON(container.profile(id), prof); | ||
} | ||
|
||
export const forgeCompat = { | ||
shouldUseVenv, | ||
getModLoaderUrl, | ||
downloadModLoader, | ||
patchProfile | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"mod-loader": { | ||
"1.2.4": "https://github.com/skjsjhb/ModLoader-Binaries/releases/download/1.0/ModLoader.1.2.4.zip", | ||
"1.2.3": "https://github.com/skjsjhb/ModLoader-Binaries/releases/download/1.0/ModLoader.1.2.3.zip", | ||
"1.1": "https://github.com/skjsjhb/ModLoader-Binaries/releases/download/1.0/ModLoader.1.1.zip" | ||
}, | ||
"damt": { | ||
"name": "damt:damt:0.1", | ||
"downloads": { | ||
"artifact": { | ||
"url": "https://github.com/skjsjhb/ModLoader-Binaries/releases/download/1.0/damt-0.1.jar" | ||
} | ||
} | ||
}, | ||
"damt-arg": "--tweakClass damt.ModLoaderTweaker", | ||
"venv": [ | ||
"1.5.1", | ||
"1.5", | ||
"1.4.7", | ||
"1.4.6", | ||
"1.4.5", | ||
"1.4.4", | ||
"1.4.3", | ||
"1.4.2", | ||
"1.4.1", | ||
"1.4", | ||
"1.3.2", | ||
"1.2.5", | ||
"1.2.4", | ||
"1.2.3", | ||
"1.1" | ||
] | ||
} |