Skip to content

Commit cbfdb2e

Browse files
committed
fix: 🐛 genesis launch
1 parent 4897eab commit cbfdb2e

File tree

2 files changed

+33
-56
lines changed

2 files changed

+33
-56
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.DS_Store
22
node_modules
33
/dist
4-
LauncherMetadata.json
4+
LauncherMetadata.jsonc
55

66

77
# local env files

src/javascript/minecraft.js

+32-55
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,10 @@ export async function checkGameFiles(metadata) {
224224
});
225225

226226
if (
227-
!(await fs.exists(
228-
join(constants.DOTLUNARCLIENT, 'offline', await settings.get('version'))
229-
))
227+
!(await fs.exists(join(constants.DOTLUNARCLIENT, 'offline', 'multiver')))
230228
) {
231229
await fs
232-
.mkdir(
233-
join(constants.DOTLUNARCLIENT, 'offline', await settings.get('version'))
234-
)
230+
.mkdir(join(constants.DOTLUNARCLIENT, 'offline', 'multiver'))
235231
.catch((error) => {
236232
logger.error('Failed to create version folder', error);
237233
});
@@ -242,7 +238,7 @@ export async function checkGameFiles(metadata) {
242238
const gameFilePath = join(
243239
constants.DOTLUNARCLIENT,
244240
'offline',
245-
await settings.get('version'),
241+
'multiver',
246242
artifact.name
247243
);
248244
logger.debug(
@@ -254,12 +250,7 @@ export async function checkGameFiles(metadata) {
254250
if (!(await fs.exists(gameFilePath))) {
255251
await downloadAndSaveFile(
256252
artifact.url,
257-
join(
258-
constants.DOTLUNARCLIENT,
259-
'offline',
260-
await settings.get('version'),
261-
artifact.name
262-
),
253+
join(constants.DOTLUNARCLIENT, 'offline', 'multiver', artifact.name),
263254
'blob',
264255
artifact.sha1,
265256
'sha1'
@@ -289,38 +280,18 @@ export async function checkNatives(metadata) {
289280
);
290281
if (
291282
await fs.exists(
292-
join(
293-
constants.DOTLUNARCLIENT,
294-
'offline',
295-
await settings.get('version'),
296-
artifact.name
297-
)
283+
join(constants.DOTLUNARCLIENT, 'offline', 'multiver', artifact.name)
298284
)
299285
) {
300286
if (
301287
!(await fs.exists(
302-
join(
303-
constants.DOTLUNARCLIENT,
304-
'offline',
305-
await settings.get('version'),
306-
'natives'
307-
)
288+
join(constants.DOTLUNARCLIENT, 'offline', 'multiver', 'natives')
308289
))
309290
) {
310291
await extractZip(
311-
join(
312-
constants.DOTLUNARCLIENT,
313-
'offline',
314-
await settings.get('version'),
315-
artifact.name
316-
),
292+
join(constants.DOTLUNARCLIENT, 'offline', 'multiver', artifact.name),
317293
{
318-
dir: join(
319-
constants.DOTLUNARCLIENT,
320-
'offline',
321-
await settings.get('version'),
322-
'natives'
323-
),
294+
dir: join(constants.DOTLUNARCLIENT, 'offline', 'multiver', 'natives'),
324295
}
325296
)
326297
.then(() => {
@@ -528,7 +499,7 @@ export async function getJavaArguments(
528499
const natives = join(
529500
constants.DOTLUNARCLIENT,
530501
'offline',
531-
await settings.get('version'),
502+
'multiver',
532503
'natives'
533504
);
534505

@@ -543,8 +514,8 @@ export async function getJavaArguments(
543514
let version = await settings.get('version');
544515
if (overrideVersion) version = overrideVersion;
545516

546-
const lunarJarFile = async (filename) =>
547-
`"${join(constants.DOTLUNARCLIENT, 'offline', version, filename)}"`;
517+
const lunarJarFile = (filename) =>
518+
`"${join(constants.DOTLUNARCLIENT, 'offline', 'multiver', filename)}"`;
548519

549520
const gameDir =
550521
(await settings.get('launchDirectories')).find(
@@ -560,30 +531,27 @@ export async function getJavaArguments(
560531

561532
// Make sure the patcher exists, or else the game will crash (jvm init error)
562533
stat(patcherPath)
563-
.then(() =>
534+
.then(() => {
564535
args.push(
565536
`-javaagent:"${patcherPath}"="${join(
566537
constants.DOTLUNARCLIENT,
567538
'solartweaks',
568539
constants.PATCHER.CONFIG
569540
)}"`
570-
)
571-
)
541+
);
542+
})
572543
.catch((e) =>
573544
logger.warn(
574545
`Not adding patcher in arguments; ${patcherPath} does not exist! ${e}`
575546
)
576547
);
577548

578-
const classPath = [
579-
await lunarJarFile('lunar-assets-prod-1-optifine.jar'),
580-
await lunarJarFile('lunar-assets-prod-2-optifine.jar'),
581-
await lunarJarFile('lunar-assets-prod-3-optifine.jar'),
582-
await lunarJarFile('lunar-prod-optifine.jar'),
583-
await lunarJarFile('lunar-libs.jar'),
584-
await lunarJarFile('vpatcher-prod.jar'),
585-
await lunarJarFile('Optifine.jar'),
586-
];
549+
const classPath = [];
550+
metadata.launchTypeData.artifacts
551+
.filter((a) => a.type === 'CLASS_PATH')
552+
.forEach(async (artifact) => {
553+
classPath.push(lunarJarFile(artifact.name));
554+
});
587555

588556
if (version === '1.7')
589557
classPath.push(await lunarJarFile('OptiFine_1.7.10_HD_U_E7'));
@@ -613,7 +581,16 @@ export async function getJavaArguments(
613581
'--width',
614582
resolution.width,
615583
'--height',
616-
resolution.height
584+
resolution.height,
585+
'--ichorClassPath',
586+
classPath.join(),
587+
'--ichorExternalFiles',
588+
metadata.launchTypeData.artifacts.find((a) => a.type === 'EXTERNAL_FILE')
589+
.name,
590+
'--workingDirectory',
591+
'.',
592+
'--classpathDir',
593+
join(constants.DOTLUNARCLIENT, 'offline', 'multiver')
617594
);
618595

619596
if (serverIp) args.push('--server', `"${serverIp}"`);
@@ -636,11 +613,11 @@ export async function launchGame(metadata, serverIp = null, debug = false) {
636613
const version = await settings.get('version');
637614
const args = await getJavaArguments(metadata, serverIp);
638615

639-
logger.debug('Launching game with args', args);
616+
logger.debug('Launching game with args\n\n', args.join('\n'));
640617

641618
const javaPath = join(await settings.get('jrePath'), 'java');
642619
const proc = await spawn(javaPath, args, {
643-
cwd: join(constants.DOTLUNARCLIENT, 'offline', version),
620+
cwd: join(constants.DOTLUNARCLIENT, 'offline', 'multiver'),
644621
detached: true,
645622
shell: debug,
646623
});

0 commit comments

Comments
 (0)