@goindog-network-studio/openmlauncher
v1.2.8
Published
An Open-Source Library that provide some method about Minecraft launcher.(Without UI, just APIs)
Readme
OpenMLauncher
A library that provides functions to manage your Minecraft game. With window app framework (e.g. Electron) might be more awesome! Here is one version which is based on Node.js and is used by Node.js applications.
Installation
To Install, you just input the following command at the root of your Node.js project.
npm i @goindog-network-studio/openmlauncherEnvironment Variables
gameDir - The directory that storage game files.
configDir - The directory that save OpenMLauncher configs.
APIs
Common Objects
oml.Game - Download, install and launch any-version Minecraft.
oml.Account - Manage accounts that provides to log-in Minecraft.
oml.Runtime - Manage JRE [ get all runtimes that are installed, install specified JRE version that doesn't exist ] on your computer.
Examples
We provides many functions to install and launch games in library.
Get whole Minecraft versions
import { oml } from '@goindog-network-studio/openmlauncher';
oml.Game.Vanilla.getAllVersions()Install specified version
import { oml } from '@goindog-network-studio/openmlauncher'
oml.Game.Vanilla.Install(version)The parameter version is the version which you'd like to install.
Add an account to log-in Minecraft
Attention: Logging-in Microsoft account requires an Azure AD Application. Make sure you own your personal client_id.
From May 30th 2023 on, Mojang Studios requires 3rd-party Minecraft launcher to apply for access to get player profile. When you finished registering Azure AD Application, go to Application Form to apply the access.
Before you use the following function, specifies one logging-in mode. We provides AuthorizationMode.DeviceCode and AuthorizationMode.AuthorizationCode
import { oml, AuthorizationMode } from '@goindog-network-studio/openmlauncher'
oml.Account.add(method, client_id);User data will be saved at ${configDir}/.oml/user.config through encoding.
Custom Launch Parameters Setting
Use oml.Game.Launch(name, client_id, options?) to launch any-version Minecraft that is installed on your computer.
options is an object that contains these custom settings:
options = {
custom_params: {
game: {},
jvm: {}
},
refresh_user: true
}The object custom_params define parameters that will be used during launching Minecraft. It storages through key-value couple.
For example, if you want to set window size, you can add "--width": 480 and "--height": 480 in options.custom_params.game.
ATTENTION custom_params doesn't support overwriting parameters that exist in <version>.json
The parameter refresh_user decides that user will or not refresh its access token. If true, the parameter client_id is required.
Using Suggestions
We recommend to create short-term JRE at the root of Minecraft directory in order to avoid making any mistakes. JDK-Utils library catches one bug is that it couldn't search the whole JREs that exsist on your computer, which cause older versions will throw dependency-repeat exception.
