changes to getLaunchOptions so tweaks arent hard coded

This commit is contained in:
Pierce 2019-02-08 15:18:07 -05:00
parent 1c097c6ae3
commit edaf35dcd8
3 changed files with 19 additions and 9 deletions

View file

@ -177,7 +177,7 @@ module.exports.getForgeDependencies = async function(root, version, forgeJarPath
await downloadAsync(downloadLink, jarPath, name); await downloadAsync(downloadLink, jarPath, name);
paths.push(`${jarPath}\\${name}`); paths.push(`${jarPath}\\${name}`);
}) });
await Promise.all(download); await Promise.all(download);
@ -212,9 +212,14 @@ module.exports.getClasses = function (root, version) {
}); });
}; };
module.exports.getLaunchOptions = function (version, options) { module.exports.getLaunchOptions = function (version, forge, options) {
return new Promise(resolve => { return new Promise(resolve => {
let arguments = version.minecraftArguments ? version.minecraftArguments.split(' ') : version.arguments.game; let arguments;
if(forge) {
arguments = forge.minecraftArguments ? forge.minecraftArguments.split(' ') : forge.arguments.game;
} else {
arguments = version.minecraftArguments ? version.minecraftArguments.split(' ') : version.arguments.game;
}
const fields = { const fields = {
'${auth_access_token}': options.authorization.access_token, '${auth_access_token}': options.authorization.access_token,
'${auth_session}': options.authorization.access_token, '${auth_session}': options.authorization.access_token,

View file

@ -27,7 +27,7 @@ module.exports = async function (options) {
forge = await handler.getForgeDependencies(options.root, versionFile, options.forge.path); forge = await handler.getForgeDependencies(options.root, versionFile, options.forge.path);
} }
const args = [] const args = [];
// Jvm // Jvm
let jvm = [ let jvm = [
@ -40,9 +40,10 @@ module.exports = async function (options) {
'-Xincgc' '-Xincgc'
]; ];
jvm.push(await handler.getJVM(versionFile, options)); jvm.push(await handler.getJVM(versionFile, options));
if(options.customArgs) jvm = jvm.concat(options.customArgs);
const classes = await handler.getClasses(options.root, versionFile);
let mainClass; let mainClass;
const classes = await handler.getClasses(options.root, versionFile);
const classPaths = []; const classPaths = [];
if(forge) { if(forge) {
classPaths.push(`${options.forge.path};${forge.paths.join(';')};${classes.join(';')};${mcPath}`); classPaths.push(`${options.forge.path};${forge.paths.join(';')};${classes.join(';')};${mcPath}`);
@ -57,14 +58,18 @@ module.exports = async function (options) {
await handler.getAssets(options.root, versionFile); await handler.getAssets(options.root, versionFile);
// Launch options // Launch options
const launchOptions = await handler.getLaunchOptions(versionFile, options); let launchOptions;
if(forge) launchOptions.push('--tweakClass net.minecraftforge.fml.common.launcher.FMLTweaker'); if(forge) {
launchOptions = await handler.getLaunchOptions(versionFile, forge.forge, options);
} else {
launchOptions = await handler.getLaunchOptions(versionFile, null, options);
}
// NOTE: Hacky way of setting up launch options, will rework this next update. // NOTE: Hacky way of setting up launch options, will rework this next update.
let launchArguments = args.concat(jvm, classPaths, launchOptions); let launchArguments = args.concat(jvm, classPaths, launchOptions);
if(forge) launchArguments = `${jvm.join(' ')} -cp ${classPaths} ${mainClass} ${launchOptions.join(' ')}`.split(' '); if(forge) launchArguments = `${jvm.join(' ')} -cp ${classPaths} ${mainClass} ${launchOptions.join(' ')}`.split(' ');
const minecraft = child.spawn(`java`, launchArguments) const minecraft = child.spawn(`java`, launchArguments);
event.emit('start', null); event.emit('start', null);
minecraft.stdout.on('data', (data) => event.emit('data', data)); minecraft.stdout.on('data', (data) => event.emit('data', data));
minecraft.stderr.on('data', (data) => event.emit('error', data)); minecraft.stderr.on('data', (data) => event.emit('error', data));

View file

@ -1,6 +1,6 @@
{ {
"name": "minecraft-launcher-core", "name": "minecraft-launcher-core",
"version": "2.0.1", "version": "2.1.0",
"description": "Module that downloads Minecraft assets and runs Minecraft. Also Supports Forge", "description": "Module that downloads Minecraft assets and runs Minecraft. Also Supports Forge",
"main": "index.js", "main": "index.js",
"dependencies": { "dependencies": {