From 22baef8735bdf50904bc472c3b9f3e29c9d6543e Mon Sep 17 00:00:00 2001 From: Pierce Date: Mon, 5 Aug 2019 10:30:06 -0400 Subject: [PATCH] moved error to data. Read DESC before you go "wait what the f*ck", in older versions, the minecraft process emits data to `error` instead of normal `data`. In newer versions, errors and data are all processed through `data`, making `error` pointless. --- README.md | 9 ++++++--- components/handler.js | 3 ++- components/launcher.js | 4 ++-- package.json | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d408f6d..aaa65ba 100644 --- a/README.md +++ b/README.md @@ -73,16 +73,20 @@ launcher.on('error', (e) => console.log(e.toString('utf-8'))); | `options.window.width` | String | Width of the Minecraft Client | False | | `options.window.height` | String | Height of the Minecraft Client. | False | | `options.overrides` | Object | Json object redefining paths for better customization. Example below. | False | +| `options.overrides` | Object | Json object redefining paths for better customization. Example below. | False | +| `options.overrides.minArgs`| Integer| The amount of launch arguments specified in the version file before it adds the default again| False | ```js let opts = { otherOps..., overrides: { minecraftJar: "", versionJson: "", - directory: "", + directory: "", // where the minecraft jar and version json are located. libraries: "", natives: "", - assetRoot: "" + assetRoot: "", + classes: [], // all class paths are required if you use this. + minArgs: 11, } } ``` @@ -147,7 +151,6 @@ You'll need to provide the folder created in the versions if you're running the | `arguments` | Object | Emitted when launch arguments are set for the Minecraft Jar. | | `data` | Buffer | Emitted when information is returned from the Minecraft Process | | `close` | Integer | Code number that is returned by the Minecraft Process | -| `error` | String | Emitted when the Minecraft Process errors | | `package-extract` | null | Emitted when `clientPackage` finishes being extracted | | `download` | String | Emitted when a file successfully downloads | | `download-status` | Object | Emitted when data is received while downloading | diff --git a/components/handler.js b/components/handler.js index 6e97fd0..2f82877 100644 --- a/components/handler.js +++ b/components/handler.js @@ -323,7 +323,8 @@ class Handler { const assetRoot = this.options.overrides.assetRoot || path.join(this.options.root, 'assets'); const assetPath = this.version.assets === "legacy" || this.version.assets === "pre-1.6" ? path.join(assetRoot, 'legacy') : path.join(assetRoot); - if(args.length < 11) args = args.concat(this.version.minecraftArguments ? this.version.minecraftArguments.split(' ') : this.version.arguments.game); + const minArgs = this.options.overrides.minArgs || 5; + if(args.length < minArgs) args = args.concat(this.version.minecraftArguments ? this.version.minecraftArguments.split(' ') : this.version.arguments.game); if({}.toString.call(this.options.authorization) === "[object Promise]") { this.options.authorization = await this.options.authorization; diff --git a/components/launcher.js b/components/launcher.js index e08a3a0..f312158 100644 --- a/components/launcher.js +++ b/components/launcher.js @@ -86,7 +86,7 @@ class MCLCore extends EventEmitter { if(this.options.customArgs) jvm = jvm.concat(this.options.customArgs); - const classes = await handler.cleanUp(await this.handler.getClasses()); + const classes = this.options.overrides.classes || await handler.cleanUp(await this.handler.getClasses()); let classPaths = ['-cp']; const separator = this.handler.getOS() === "windows" ? ";" : ":"; this.emit('debug', `[MCLC]: Using ${separator} to separate class paths`); @@ -115,7 +115,7 @@ class MCLCore extends EventEmitter { const minecraft = child.spawn(this.options.javaPath ? this.options.javaPath : 'java', launchArguments); minecraft.stdout.on('data', (data) => this.emit('data', data)); - minecraft.stderr.on('data', (data) => this.emit('error', data)); + minecraft.stderr.on('data', (data) => this.emit('data', data)); minecraft.on('close', (code) => this.emit('close', code)); return minecraft; diff --git a/package.json b/package.json index 04abfaa..9049af7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "minecraft-launcher-core", - "version": "3.7.2", + "version": "3.7.3", "description": "Lightweight module that downloads and runs Minecraft using javascript / NodeJS", "main": "index.js", "dependencies": {