feat: add a function to launch the game
This commit is contained in:
parent
34f09868f3
commit
3db0007789
5 changed files with 51 additions and 17 deletions
|
|
@ -122,7 +122,29 @@ export async function generateLaunchArguments(
|
||||||
p(game, arg);
|
p(game, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.customJvm !== "") {
|
||||||
|
for (const arg of options.customJvm.split(" ")) {
|
||||||
|
jvm.push(arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const log4j = await getArgument(versionManifest, gameRoot);
|
const log4j = await getArgument(versionManifest, gameRoot);
|
||||||
|
|
||||||
return `${getJavaExecutable(javaRoot)} ${jvm.join(" ")}${options.customJvm === "" ? "" : ` ${options.customJvm}`} -Xms${options.minRam} -Xmx${options.maxRam} -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M ${log4j} ${versionManifest.mainClass} ${game.join(" ")}`;
|
return {
|
||||||
|
command: getJavaExecutable(javaRoot),
|
||||||
|
args: [
|
||||||
|
...jvm,
|
||||||
|
`-Xms${options.minRam}`,
|
||||||
|
`-Xmx${options.maxRam}`,
|
||||||
|
"-XX:+UnlockExperimentalVMOptions",
|
||||||
|
"-XX:+UseG1GC",
|
||||||
|
"-XX:G1NewSizePercent=20",
|
||||||
|
"-XX:G1ReservePercent=20",
|
||||||
|
"-XX:MaxGCPauseMillis=50",
|
||||||
|
"-XX:G1HeapRegionSize=32M",
|
||||||
|
log4j,
|
||||||
|
versionManifest.mainClass,
|
||||||
|
...game,
|
||||||
|
],
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
export * as version from "./version";
|
|
||||||
export * as arguments from "./arguments";
|
|
||||||
export * as log4j from "./log4j";
|
|
||||||
|
|
||||||
export { AssetsDownloader } from "./assets";
|
export { AssetsDownloader } from "./assets";
|
||||||
export { LibrariesDownloader } from "./libraries";
|
export { LibrariesDownloader } from "./libraries";
|
||||||
export { NativesDownloader } from "./natives";
|
export { NativesDownloader } from "./natives";
|
||||||
export * as java from "./java";
|
export * as java from "./java";
|
||||||
|
export * as version from "./version";
|
||||||
|
export * as arguments from "./arguments";
|
||||||
|
export * as log4j from "./log4j";
|
||||||
|
export { launch } from "./launch";
|
||||||
|
|
|
||||||
15
src/core/launch.ts
Normal file
15
src/core/launch.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { spawn } from "child_process";
|
||||||
|
import { LaunchArguments } from "../utils/types";
|
||||||
|
|
||||||
|
export function launch(
|
||||||
|
launchArguments: LaunchArguments,
|
||||||
|
gameRoot: string,
|
||||||
|
detached = false,
|
||||||
|
) {
|
||||||
|
console.log(gameRoot)
|
||||||
|
const process = spawn(launchArguments.command, launchArguments.args, { detached });
|
||||||
|
|
||||||
|
console.log(process.spawnargs.join(" "))
|
||||||
|
|
||||||
|
return process;
|
||||||
|
}
|
||||||
|
|
@ -175,3 +175,5 @@ export type Auth = {
|
||||||
clientId: string;
|
clientId: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type LaunchArguments = { command: string; args: string[] }
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue