@kzheart_/mc-pilot 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { mkdir } from "node:fs/promises";
|
|
1
|
+
import { access, mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
2
3
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
3
4
|
import { MinecraftFolder, Version } from "@xmcl/core";
|
|
4
5
|
import { getVersionList, installDependencies, installFabric, installVersion } from "@xmcl/installer";
|
|
@@ -53,6 +54,16 @@ export async function prepareManagedFabricRuntime(variant, runtimeOptions, depen
|
|
|
53
54
|
const { runtimeRootDir, gameDir } = runtimeOptions;
|
|
54
55
|
await mkdir(runtimeRootDir, { recursive: true });
|
|
55
56
|
await mkdir(gameDir, { recursive: true });
|
|
57
|
+
const expectedVersionId = `${variant.minecraftVersion}-fabric${loaderVersion}`;
|
|
58
|
+
const readyMarker = path.join(runtimeRootDir, `.ready-${expectedVersionId}`);
|
|
59
|
+
try {
|
|
60
|
+
await access(readyMarker);
|
|
61
|
+
// Runtime already prepared, skip download
|
|
62
|
+
return { runtimeRootDir, gameDir, versionId: expectedVersionId };
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
// Not ready, proceed with download
|
|
66
|
+
}
|
|
56
67
|
const minecraft = new MinecraftFolder(runtimeRootDir);
|
|
57
68
|
const versionList = await getVersionList({ fetch: fetchImpl });
|
|
58
69
|
const versionMeta = versionList.versions.find((entry) => entry.id === variant.minecraftVersion);
|
|
@@ -66,24 +77,25 @@ export async function prepareManagedFabricRuntime(variant, runtimeOptions, depen
|
|
|
66
77
|
side: "client",
|
|
67
78
|
dispatcher: DOWNLOAD_DISPATCHER
|
|
68
79
|
});
|
|
69
|
-
const
|
|
80
|
+
const installedVersionId = await installFabric({
|
|
70
81
|
minecraftVersion: variant.minecraftVersion,
|
|
71
82
|
version: loaderVersion,
|
|
72
83
|
minecraft,
|
|
73
84
|
side: "client",
|
|
74
85
|
fetch: fetchImpl
|
|
75
86
|
});
|
|
76
|
-
const resolvedVersion = await Version.parse(minecraft,
|
|
87
|
+
const resolvedVersion = await Version.parse(minecraft, installedVersionId);
|
|
77
88
|
await installDependencies(resolvedVersion, {
|
|
78
89
|
side: "client",
|
|
79
90
|
dispatcher: DOWNLOAD_DISPATCHER,
|
|
80
91
|
assetsDownloadConcurrency: 2,
|
|
81
92
|
librariesDownloadConcurrency: 2
|
|
82
93
|
});
|
|
83
|
-
await applyArm64LwjglPatch(runtimeRootDir,
|
|
94
|
+
await applyArm64LwjglPatch(runtimeRootDir, installedVersionId, { fetchImpl });
|
|
95
|
+
await writeFile(readyMarker, new Date().toISOString(), "utf8");
|
|
84
96
|
return {
|
|
85
97
|
runtimeRootDir,
|
|
86
98
|
gameDir,
|
|
87
|
-
versionId
|
|
99
|
+
versionId: installedVersionId
|
|
88
100
|
};
|
|
89
101
|
}
|