2019-04-28 04:36:18 +03:00
|
|
|
![logo](https://pierce.is-serious.business/44U1xXh.png)
|
2019-05-23 03:24:53 +03:00
|
|
|
##### This project is near complete.
|
|
|
|
[![Build Status](https://travis-ci.com/Pierce01/MinecraftLauncher-core.svg?branch=master)](https://travis-ci.com/Pierce01/MinecraftLauncher-core)
|
2018-10-30 01:13:58 +03:00
|
|
|
|
2019-02-11 05:21:14 +03:00
|
|
|
MCLC is a NodeJS solution for launching modded and vanilla Minecraft without having to download and format everything yourself.
|
|
|
|
Basically a core for your Electron or script based launchers.
|
2018-10-30 01:13:58 +03:00
|
|
|
|
2019-04-19 00:56:36 +03:00
|
|
|
### Getting support
|
|
|
|
Since people seem to use this, I've created a Discord server for anyone who needs to get in contact with me or get help!
|
|
|
|
https://discord.gg/8uYVbXP
|
|
|
|
|
2018-12-31 02:35:47 +03:00
|
|
|
### Installing
|
2018-12-10 02:17:20 +03:00
|
|
|
|
|
|
|
`npm i minecraft-launcher-core`
|
|
|
|
|
2019-03-11 03:18:49 +03:00
|
|
|
### Standard Example
|
|
|
|
```javascript
|
2019-05-23 01:28:48 +03:00
|
|
|
const { Client, Authenticator } = require('minecraft-launcher-core');
|
|
|
|
|
|
|
|
let opts = {
|
|
|
|
clientPackage: null,
|
2019-06-06 21:49:18 +03:00
|
|
|
authorization: Authenticator.getAuth("username", "password"),
|
2019-05-23 01:28:48 +03:00
|
|
|
root: "./minecraft",
|
|
|
|
os: "windows",
|
|
|
|
version: {
|
|
|
|
number: "1.14",
|
|
|
|
type: "release"
|
2019-05-23 01:32:45 +03:00
|
|
|
},
|
2019-05-23 01:28:48 +03:00
|
|
|
memory: {
|
|
|
|
max: "6000",
|
|
|
|
min: "4000"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-06 21:49:18 +03:00
|
|
|
const launcher = new Client();
|
|
|
|
launcher.launch(opts);
|
2019-05-23 01:28:48 +03:00
|
|
|
|
|
|
|
launcher.on('debug', (e) => console.log(e));
|
2019-06-23 05:54:27 +03:00
|
|
|
launcher.on('data', (e) => console.log(e.toString('utf-8')));
|
|
|
|
launcher.on('error', (e) => console.log(e.toString('utf-8')));
|
2019-03-11 03:18:49 +03:00
|
|
|
```
|
2019-06-06 21:49:18 +03:00
|
|
|
### Documentation
|
2018-10-30 01:13:58 +03:00
|
|
|
|
2019-06-06 21:49:18 +03:00
|
|
|
#### Client Functions
|
|
|
|
|
|
|
|
| Function | Type | Description |
|
|
|
|
|----------|---------|-----------------------------------------------------------------------------------------|
|
2019-06-08 21:21:15 +03:00
|
|
|
| `launch` | Promise | Launches the client with the specified `options` as a parameter. Returns child the process |
|
2019-06-06 21:49:18 +03:00
|
|
|
|
|
|
|
##### launch
|
2019-05-23 01:28:48 +03:00
|
|
|
|
|
|
|
| Parameter | Type | Description | Required |
|
|
|
|
|--------------------------|----------|-------------------------------------------------------------------------------------------|----------|
|
|
|
|
| `options.clientPackage` | String | Path to the client package zip file. | False |
|
2019-07-19 13:38:29 +03:00
|
|
|
| `options.installer` | String | Path to installer being executed. | False |
|
2019-05-23 01:28:48 +03:00
|
|
|
| `options.root` | String | Path where you want the launcher to work in. like `C:/Users/user/AppData/Roaming/.mc`, | True |
|
2019-06-08 21:21:15 +03:00
|
|
|
| `options.os` | String | windows, osx or linux. MCLC with auto determine the OS if this field isn't provided. | False |
|
2019-05-23 01:28:48 +03:00
|
|
|
| `options.version.number` | String | Minecraft version that is going to be launched. | True |
|
|
|
|
| `options.version.type` | String | Any string. The actual Minecraft launcher uses `release` and `snapshot`. | True |
|
2019-06-23 05:55:43 +03:00
|
|
|
| `options.version.custom` | String | The name of the folder, jar file, and version json in the version folder. | False |
|
2019-07-19 13:38:29 +03:00
|
|
|
| `options.memory.max` | String | Max amount of memory being used by Minecraft. | True |
|
|
|
|
| `options.memory.min` | String | Min amount of memory being used by Minecraft. | True |
|
|
|
|
| `options.forge` | String | Path to Universal Forge Jar. (Only for versions below 1.13+ | False |
|
2019-06-06 21:49:18 +03:00
|
|
|
| `options.javaPath` | String | Path to the JRE executable file, will default to `java` if not entered. | False |
|
2019-05-23 01:28:48 +03:00
|
|
|
| `options.server.host` | String | Host url to the server, don't include the port. | False |
|
|
|
|
| `options.server.port` | String | Port of the host url, will default to `25565` if not entered. | False |
|
|
|
|
| `options.proxy.host` | String | Host url to the proxy, don't include the port. | False |
|
|
|
|
| `options.proxy.port` | String | Port of the host proxy, will default to `8080` if not entered. | False |
|
|
|
|
| `options.proxy.username` | String | Username for the proxy. | False |
|
|
|
|
| `options.proxy.password` | String | Password for the proxy. | False |
|
2019-05-26 23:42:23 +03:00
|
|
|
| `options.timeout` | Integer | Timeout on download requests. | False |
|
|
|
|
| `options.window.width` | String | Width of the Minecraft Client | False |
|
|
|
|
| `options.window.height` | String | Height of the Minecraft Client. | False |
|
|
|
|
|
2019-07-19 13:38:29 +03:00
|
|
|
#### Notes
|
|
|
|
##### Custom
|
2019-05-11 05:10:38 +03:00
|
|
|
If you are loading up a client outside of vanilla Minecraft or Forge (Optifine and for an example), you'll need to download the needed files yourself
|
|
|
|
if you don't provide downloads url downloads like Forge and Fabric. Still need to provide the version jar.
|
2019-07-19 13:38:29 +03:00
|
|
|
##### Installer
|
|
|
|
You'll need to provide the folder created in the versions if you're running the new forge like so
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"version": {
|
|
|
|
"number": "1.14.2",
|
|
|
|
"type": "release",
|
|
|
|
"custom": "1.14.2-forge-26.0.63"
|
|
|
|
},
|
|
|
|
"installer": "forge-1.14.2-26.0.63-installer.jar"
|
|
|
|
}
|
|
|
|
```
|
2019-05-23 01:28:48 +03:00
|
|
|
#### Authenticator Functions
|
2018-12-31 02:35:47 +03:00
|
|
|
|
|
|
|
##### getAuth
|
|
|
|
|
|
|
|
| Parameter | Type | Description | Required |
|
|
|
|
|-----------|--------|--------------------------------------------------------------|----------|
|
2019-05-24 02:40:34 +03:00
|
|
|
| `username`| String | Email or username | True |
|
|
|
|
| `password`| String | Password for the Mojang account being used if online mode. | False |
|
2018-12-31 02:35:47 +03:00
|
|
|
|
|
|
|
##### validate
|
|
|
|
|
|
|
|
| Parameter | Type | Description | Required |
|
|
|
|
|--------------|--------|-------------------------------------------------------------------|----------|
|
|
|
|
| `access_token` | String | Token being checked if it can be used to login with (online mode). | True |
|
|
|
|
|
|
|
|
##### refreshAuth
|
|
|
|
|
|
|
|
| Parameter | Type | Description | Required |
|
|
|
|
|--------------------|--------|-------------------------------------------------------------------------------------|----------|
|
|
|
|
| `access_token` | String | Token being checked if it can be used to login with (online mode). | True |
|
|
|
|
| `client_token` | String | Token being checked if it's the same client that the access_token was created from. | True |
|
2019-07-19 13:38:29 +03:00
|
|
|
| `selected_profile` | Object | Json Object that was returned from Mojang's auth api. | True |
|
2018-12-31 02:35:47 +03:00
|
|
|
|
2019-05-23 01:28:48 +03:00
|
|
|
##### invalidate
|
|
|
|
|
|
|
|
| Parameter | Type | Description | Required |
|
|
|
|
|--------------|--------|-------------------------------------------------------------------|----------|
|
|
|
|
| `access_token` | String | Token being checked if it can be used to login with (online mode). | True |
|
|
|
|
| `client_token` | String | Token being checked if it's the same client that the access_token was created from. | True |
|
|
|
|
|
|
|
|
##### signOut
|
|
|
|
|
|
|
|
| Parameter | Type | Description | Required |
|
|
|
|
|--------------|--------|--------------------------------------|----------|
|
|
|
|
| `username` | String | Username used to login with | True |
|
|
|
|
| `password` | String | Password used to login with | True |
|
|
|
|
|
2019-02-08 22:02:42 +03:00
|
|
|
#### Events
|
|
|
|
|
2019-02-11 05:21:14 +03:00
|
|
|
| Event Name | Type | Description |
|
|
|
|
|-------------------|---------|---------------------------------------------------------------------------------------|
|
2019-04-26 20:03:39 +03:00
|
|
|
| `arguments` | Object | Emitted when launch arguments are set for the Minecraft Jar. |
|
2019-02-11 05:21:14 +03:00
|
|
|
| `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 |
|
2019-04-29 00:52:37 +03:00
|
|
|
| `debug` | String | Emitted when functions occur, made to help debug if errors occur |
|
2019-02-08 22:02:42 +03:00
|
|
|
|
2018-12-01 22:30:58 +03:00
|
|
|
|
2018-10-30 01:40:52 +03:00
|
|
|
#### What should it look like running from console?
|
2019-06-06 21:49:18 +03:00
|
|
|
Showing the emitted information from debug and data, also using `getPid` after the process has been created.
|
|
|
|
![gif](https://pierce.is-serious.business/3N3PMC4.gif)
|