pimi-launcher-core/README.md

146 lines
6.5 KiB
Markdown
Raw Normal View History

2018-10-30 01:13:58 +03:00
# Minecraft Launcher Core
### Currently only supports MC 1.7.3 and up.
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
2018-12-31 02:35:47 +03:00
### Installing
2018-12-10 02:17:20 +03:00
`npm i minecraft-launcher-core`
2018-12-31 02:35:47 +03:00
### Usage
2018-10-30 01:13:58 +03:00
2018-12-31 02:35:47 +03:00
##### launcher.core Options
2019-02-08 22:02:42 +03:00
| Parameter | Type | Description | Required |
|--------------------------|--------|-------------------------------------------------------------------------------------------|----------|
2018-12-31 04:47:22 +03:00
| `options.authorization` | Object | The result from `getAuth` function, allows the client to login in online or offline mode. | True |
2019-02-08 22:02:42 +03:00
| `options.clientPackage` | String | Path to the client package zip file. | False |
| `options.root` | String | Path where you want the launcher to work in. like `C:/Users/user/AppData/Roaming/.mc` | True |
| `options.os` | String | windows, osx or linux | True |
| `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 |
| `options.memory.max` | String | Max amount of memory being used by Minectaft | True |
2019-02-08 23:23:41 +03:00
| `options.forge.path` | String | Path to Universal Forge Jar | False |
2018-12-31 02:35:47 +03:00
#### launcher.authenticator Functions
##### getAuth
| Parameter | Type | Description | Required |
|-----------|--------|--------------------------------------------------------------|----------|
| `email` | String | Email or username | True |
| `password` | String | Password for the Mojang account being used if online mode. | False |
##### 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 |
| `selected_profile` | Object | Json Object that was returned from Mojangs auth api. | True |
2019-02-08 22:02:42 +03:00
#### Events
| Event Name | Type | Description |
|-------------------|---------|---------------------------------------------------------------------------------------|
| `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 |
2019-02-08 23:23:41 +03:00
| `start` | null | Emitted after `launchArguments` are set. THIS WILL BE DEPRECATED AS ITS NOT ACCURATE |
| `download` | String | Emitted when a file successfully downloads |
| `download-status` | Object | Emitted when data is received while downloading |
2018-12-31 02:35:47 +03:00
#### Client Package Function
Client Packages allow the client to run offline on setup. This function should be used outside the actual launcher.
this function is in the `handler` component.
##### makePackage
| Parameter | Type | Description | Required |
|------------|--------|-----------------------------------------------------------------------|----------|
| `versions` | Array | Array of the versions being downloaded and being made into a package. | True |
| `os` | String | OS that the package will be loaded on. OS specific natives need this. | True |
### Examples
2018-10-30 01:13:58 +03:00
```javascript
2018-12-31 02:35:47 +03:00
const launcher = require('minecraft-launcher-core');
2018-10-30 01:13:58 +03:00
2018-12-01 03:33:50 +03:00
launcher.authenticator.getAuth("email", "password").then(auth => {
// Save the auth to a file so it can be used later on!
2018-11-30 05:44:40 +03:00
launcher.core({
authorization: auth,
2018-12-01 22:30:58 +03:00
clientPackage: null,
2019-02-08 22:02:42 +03:00
forge: null,
2018-12-31 02:35:47 +03:00
root: "C:/Users/user/AppData/Roaming/.mc",
os: "windows",
version: {
2018-12-31 02:35:47 +03:00
number: "1.13.2",
type: "MCC-Launcher"
},
memory: {
max: "500"
}
});
});
```
##### Using Validate and Refresh
```javascript
2018-12-31 02:35:47 +03:00
let auth = require("pathToUserAuthJson.json");
const validateCheck = await launcher.authenticator.validate(auth.access_token);
if(!validateCheck) {
auth = await launcher.authenticator.refreshAuth(auth.access_token, auth.client_token, auth.selected_profile);
}
launcher.core({
authorization: auth,
clientPackage: null,
root: "directory",
os: "windows",
version: {
number: "1.13.2",
type: "MCC-Launcher"
},
memory: {
max: "500"
}
2018-11-30 05:44:40 +03:00
});
2018-12-31 02:36:50 +03:00
```
2018-12-01 22:30:58 +03:00
2019-02-08 22:02:42 +03:00
##### Using With Forge
```js
launcher.authenticator.getAuth("email", "password").then(auth => {
launcher.core({
authorization: auth,
clientPackage: null,
root: "C:/Users/user/AppData/Roaming/.mc",
forge: {
path: "C:/Users/user/Desktop/forge.jar"
},
os: "windows",
version: {
number: "1.12.2", // needs to be the same as the Forge version
type: "MCC-Launcher"
},
memory: {
max: "500"
}
});
});
```
2018-12-01 22:30:58 +03:00
2018-10-30 01:40:52 +03:00
#### What should it look like running from console?
![gif](https://pierce.is-serious.business/7d91a7.gif)