const mojang = require('mojang') const uuidV4 = require('uuid/v4') const path = require('path') const child_process = require('child_process') const ag = require('./assetguard.js') const AdmZip = require('adm-zip') const fs = require('fs') const mkpath = require('mkdirp'); function launchMinecraft(versionData, forgeData, basePath){ const authPromise = mojang.auth('email', 'pass', uuidV4(), { name: 'Minecraft', version: 1 }) authPromise.then(function(data){ console.log(data) const args = finalizeArgumentsForge(versionData, forgeData, data, basePath) //BRUTEFORCE for testing //args.push('-mods modstore\\chatbubbles\\chatbubbles\\1.0.1_for_1.11.2\\mod_chatBubbles-1.0.1_for_1.11.2.litemod,modstore\\com\\westeroscraft\\westerosblocks\\3.0.0-beta-71\\westerosblocks-3.0.0-beta-71.jar,modstore\\mezz\\jei\\1.11.2-4.3.5.277\\jei-1.11.2-4.3.5.277.jar,modstore\\net\\optifine\\optifine\\1.11.2_HD_U_B9\\optifine-1.11.2_HD_U_B9.jar') //args.push('--modListFile absolute:C:\\Users\\Asus\\Desktop\\LauncherElectron\\app\\assets\\WesterosCraft-1.11.2.json') //TODO make this dynamic const child = child_process.spawn('C:\\Program Files\\Java\\jdk1.8.0_144\\bin\\javaw.exe', args) child.stdout.on('data', (data) => { console.log('Minecraft:', data.toString('utf8')) }) child.stderr.on('data', (data) => { console.log('Minecraft:', data.toString('utf8')) }) child.on('close', (code, signal) => { console.log('Exited with code', code) }) }) } function finalizeArgumentsForge(versionData, forgeData, authData, basePath){ const mcArgs = forgeData['minecraftArguments'] const gameProfile = authData['selectedProfile'] const regex = new RegExp('\\${*(.*)}') const argArr = mcArgs.split(' ') const staticArgs = ['-Xmx4G', '-XX:+UseConcMarkSweepGC', '-XX:+CMSIncrementalMode', '-XX:-UseAdaptiveSizePolicy', '-Xmn128M', '-Djava.library.path=' + path.join(basePath, 'natives'), '-cp', classpathArg(versionData, basePath).concat(forgeClasspathArg(forgeData, basePath)).join(';'), forgeData.mainClass] for(let i=0; i -1){ shouldExclude = true } }) if(!shouldExclude){ mkpath.sync(path.join(nativePath, fileName, '..')) fs.writeFile(path.join(nativePath, fileName), zipEntries[i].getData()) } } cpArgs.push(to) } } }) //BRUTEFORCE LIB INJECTION //FOR TESTING ONLY cpArgs.push(path.join(libPath, 'com', 'mumfrey', 'liteloader', '1.11.2-SNAPSHOT', 'liteloader-1.11.2-SNAPSHOT.jar')) return cpArgs } module.exports = { launchMinecraft }