3.18.1 • Published 2 months ago

minecraft-launcher-core v3.18.1

Weekly downloads
187
License
MIT
Repository
github
Last release
2 months ago

logo

Project rewrite coming soon™

Build Status License: MIT version

MCLC (Minecraft Launcher Core) 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.

Getting support

I've created a Discord server for anyone who needs to get in contact with me or get help!

Installing

npm i minecraft-launcher-core

Standard Example

const { Client, Authenticator } = require('minecraft-launcher-core');
const launcher = new Client();

let opts = {
    // For production launchers, I recommend not passing 
    // the getAuth function through the authorization field and instead
    // handling authentication outside before you initialize
    // MCLC so you can handle auth based errors and validation!
    authorization: Authenticator.getAuth("username", "password"),
    root: "./minecraft",
    version: {
        number: "1.14",
        type: "release"
    },
    memory: {
        max: "6G",
        min: "4G"
    }
}

launcher.launch(opts);

launcher.on('debug', (e) => console.log(e));
launcher.on('data', (e) => console.log(e));

Documentation

Client Functions

FunctionTypeDescription
launchPromiseLaunches the client with the specified options as a parameter. Returns child the process
launch
ParameterTypeDescriptionRequired
options.clientPackageStringPath or URL to a zip file, which will be extracted to the root directory. (Not recommended for production use)False
options.removePackageBooleanOption to remove the client package zip file after its finished extracting.False
options.rootStringPath where you want the launcher to work in. C:/Users/user/AppData/Roaming/.mcTrue
options.cacheStringPath where launcher files will be cached in. C:/Users/user/AppData/Roaming/.mc/cacheFalse
options.osStringwindows, osx or linux. MCLC will auto determine the OS if this field isn't provided.False
options.customLaunchArgsArrayArray of custom Minecraft arguments you want to add.False
options.customArgsArrayArray of custom Java arguments you want to add.False
options.featuresArrayArray of game argument feature flags. ex: is_demo_user or has_custom_resolutionFalse
options.version.numberStringMinecraft version that is going to be launched.True
options.version.typeStringAny string. The actual Minecraft launcher uses release and snapshot.True
options.version.customStringThe name of the folder, jar file, and version json in the version folder.False
options.memory.maxStringMax amount of memory being used by Minecraft.True
options.memory.minStringMin amount of memory being used by Minecraft.True
options.forgeStringPath to Forge Jar. (Versions below 1.12.2 should be the "universal" jar while versions above 1.13 should be the "installer" jar)False
options.javaPathStringPath to the JRE executable file, will default to java if not entered.False
options.quickPlay.typeStringThe type of the quickPlay session. singleplayer, multiplayer, realms, legacyFalse
options.quickPlay.identifierStringThe folder name, server address, or realm ID, relating to the specified type. legacy follows multiplayer format.False
options.quickPlay.pathStringThe specified path for logging (relative to the run directory)False
options.proxy.hostStringHost url to the proxy, don't include the port.False
options.proxy.portStringPort of the host proxy, will default to 8080 if not entered.False
options.proxy.usernameStringUsername for the proxy.False
options.proxy.passwordStringPassword for the proxy.False
options.timeoutIntegerTimeout on download requests.False
options.window.widthStringWidth of the Minecraft Client.False
options.window.heightStringHeight of the Minecraft Client.False
options.window.fullscreenBooleanFullscreen the Minecraft Client.False
options.overridesObjectJson object redefining paths for better customization. Example below.False

IF YOU'RE NEW TO MCLC, LET IT HANDLE EVERYTHING! DO NOT USE OVERRIDES!

let opts = {
   otherOps...,
   overrides: {
       gameDirectory: '', // where the game process generates folders like saves and resource packs.
       minecraftJar: '',
       versionName: '', // replaces the value after the version flag.
       versionJson: '',
       directory: '', // where the Minecraft jar and version json are located.
       natives: '', // native directory path.
       assetRoot: '',
       assetIndex: '',
       libraryRoot: '',
       cwd: '', // working directory of the java process.
       detached: true, // whether or not the client is detached from the parent / launcher.
       classes: [], // all class paths are required if you use this.
       minArgs: 11, // The amount of launch arguments specified in the version file before it adds the default again
       maxSockets: 2, // max sockets for downloadAsync.
       // The following is for launcher developers located in countries that have the Minecraft and Forge resource servers
       // blocked for what ever reason. They obviously need to mirror the formatting of the original JSONs / file structures.
       url: {
           meta: 'https://launchermeta.mojang.com', // List of versions.
           resource: 'https://resources.download.minecraft.net', // Minecraft resources.
           mavenForge: 'http://files.minecraftforge.net/maven/', // Forge resources.
           defaultRepoForge: 'https://libraries.minecraft.net/', // for Forge only, you need to redefine the library url
                                                                // in the version json.
           fallbackMaven: 'https://search.maven.org/remotecontent?filepath='
       },
       // The following is options for which version of ForgeWrapper MCLC uses. This allows us to launch modern Forge.
       fw: {
        baseUrl: 'https://github.com/ZekerZhayard/ForgeWrapper/releases/download/',
        version: '1.5.1',
        sh1: '90104e9aaa8fbedf6c3d1f6d0b90cabce080b5a9',
        size: 29892,
      },
      logj4ConfigurationFile: ''
   }
}

Notes

Custom

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. If no version jar is specified, MCLC will default back to the normal MC jar so mods like Fabric work.

Authentication (Deprecated)

MCLC's authenticator module does not support Microsoft authentication. You will need to use a library like MSMC. If you want to create your own solution, the following is the authorization JSON object format.

{
    access_token: '',
    client_token: '',
    uuid: '',
    name: '',
    user_properties: '{}',
    meta: {
        type: 'mojang' || 'msa',
        demo: true || false, // Demo can also be specified by adding 'is_demo_user' to the options.feature array 
        // properties only exists for specific Minecraft versions.
        xuid: '',
        clientId: ''
    }
}

Authenticator Functions

getAuth
ParameterTypeDescriptionRequired
usernameStringEmail or usernameTrue
passwordStringPassword for the Mojang account being used if online mode.False
client_tokenStringClient token that will be used. If one is not specified, one will be generatedFalse
validate
ParameterTypeDescriptionRequired
access_tokenStringToken being checked if it can be used to login with (online mode).True
client_tokenStringClient token being checked to see if there was a change of client (online mode).True
refreshAuth
ParameterTypeDescriptionRequired
access_tokenStringToken being checked if it can be used to login with (online mode).True
client_tokenStringToken being checked if it's the same client that the access_token was created from.True
invalidate
ParameterTypeDescriptionRequired
access_tokenStringToken being checked if it can be used to login with (online mode).True
client_tokenStringToken being checked if it's the same client that the access_token was created from.True
signOut
ParameterTypeDescriptionRequired
usernameStringUsername used to login withTrue
passwordStringPassword used to login withTrue
changeApiUrl
ParameterTypeDescriptionRequired
urlStringNew URL that MCLC will make calls to authenticate the login.True

Events

Event NameTypeDescription
argumentsObjectEmitted when launch arguments are set for the Minecraft Jar.
dataStringEmitted when information is returned from the Minecraft Process
closeIntegerCode number that is returned by the Minecraft Process
package-extractnullEmitted when clientPackage finishes being extracted
downloadStringEmitted when a file successfully downloads
download-statusObjectEmitted when data is received while downloading
debugStringEmitted when functions occur, made to help debug if errors occur
progressObjectEmitted when files are being downloaded in order. (Assets, Forge, Natives, Classes)

What should it look like running from console?

The pid is printed in console after the process is launched. gif

Contributors

These are the people that helped out that aren't listed here!

  • Pyker - Forge dependency parsing.
  • Khionu - Research on how Minecraft'snatives are handled.
  • Coding-Kiwi - Pointed out I didn't pass clientToken in initial authentication function.
  • maxbsoft - Pointed out that a certain JVM option causes OSX Minecraft to bug out.
  • Noé - Pointed out launch args weren't being passed for Forge 1.13+.
3.18.1

2 months ago

3.18.0

2 months ago

3.17.3

6 months ago

3.17.0

11 months ago

3.17.2

9 months ago

3.17.1

11 months ago

3.16.19

11 months ago

3.16.18

1 year ago

3.16.17

1 year ago

3.16.16

2 years ago

3.16.15

2 years ago

3.16.14

2 years ago

3.16.13

2 years ago

3.16.12

2 years ago

3.16.9

2 years ago

3.16.11

2 years ago

3.16.10

2 years ago

3.16.8

3 years ago

3.16.7

3 years ago

3.16.6

3 years ago

3.16.5

3 years ago

3.16.4

3 years ago

3.16.3

3 years ago

3.16.2

3 years ago

3.16.1

3 years ago

3.16.0

3 years ago

3.15.6

3 years ago

3.15.0

4 years ago

3.14.6

4 years ago

3.14.5

4 years ago

3.14.4

4 years ago

3.14.2

4 years ago

3.14.1

4 years ago

3.14.0

4 years ago

3.13.3

4 years ago

3.13.2

4 years ago

3.13.1

4 years ago

3.13.0

4 years ago

3.12.3

4 years ago

3.12.2

4 years ago

3.12.0

4 years ago

3.11.6

4 years ago

3.11.5

4 years ago

3.11.4

4 years ago

3.11.3

5 years ago

3.11.2

5 years ago

3.11.1

5 years ago

3.10.4

5 years ago

3.10.3

5 years ago

3.10.2

5 years ago

3.10.1

5 years ago

3.10.0

5 years ago

3.9.1

5 years ago

3.9.0

5 years ago

3.8.1

5 years ago

3.8.0

5 years ago

3.7.6

5 years ago

3.7.5

5 years ago

3.7.4

5 years ago

3.7.3

5 years ago

3.7.2

5 years ago

3.7.1

5 years ago

3.7.0

5 years ago

3.6.2

5 years ago

3.6.1

5 years ago

3.5.3

5 years ago

3.5.2

5 years ago

3.5.1

5 years ago

3.5.0

5 years ago

3.4.0

5 years ago

3.3.1

5 years ago

3.3.0

5 years ago

3.2.0

5 years ago

3.1.0

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.8.1

5 years ago

2.8.0

5 years ago

2.7.0

5 years ago

2.6.2

5 years ago

2.6.1

5 years ago

2.5.7

5 years ago

2.5.6

5 years ago

2.5.5

5 years ago

2.5.4

5 years ago

2.5.3

5 years ago

2.5.2

5 years ago

2.5.1

5 years ago

2.5.0

5 years ago

2.4.2

5 years ago

2.4.1

5 years ago

2.3.1

5 years ago

2.3.0

5 years ago

2.2.0

5 years ago

2.1.3

5 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago