Skip to main content

A library for creating a custom Minecraft launcher

Project description

minecraft-launcher-lib

PyPI PyPI - Downloads PyPI - Python Version PyPI - License PyPI - Implementation Read the Docs

A Python library for creating a custom minecraft launcher. This library containts functions to install and execute minecraft and interacting with mojang accounts.

import minecraft_launcher_lib
import subprocess
import sys

# Set the data for your Azure Application here. For more information look at the documentation.
CLIENT_ID = "YOUR CLIENT ID"
REDIRECT_URL = "YOUR REDIRECT URL"

# Get latest version
latest_version = minecraft_launcher_lib.utils.get_latest_version()["release"]

# Get Minecraft directory
minecraft_directory = minecraft_launcher_lib.utils.get_minecraft_directory()

# Make sure, the latest version of Minecraft is installed
minecraft_launcher_lib.install.install_minecraft_version(latest_version, minecraft_directory)

# Login
login_url, state, code_verifier = minecraft_launcher_lib.microsoft_account.get_secure_login_data(CLIENT_ID, REDIRECT_URL)
print(f"Please open {login_url} in your browser and copy the url you are redirected into the prompt below.")
code_url = input()

# Get the code from the url
try:
    auth_code = minecraft_launcher_lib.microsoft_account.parse_auth_code_url(code_url, state)
except AssertionError:
    print("States do not match!")
    sys.exit(1)
except KeyError:
    print("Url not valid")
    sys.exit(1)

# Get the login data
login_data = minecraft_launcher_lib.microsoft_account.complete_login(CLIENT_ID, None, REDIRECT_URL, auth_code, code_verifier)

# Get Minecraft command
options = {
    "username": login_data["name"],
    "uuid": login_data["id"],
    "token": login_data["access_token"]
}
minecraft_command = minecraft_launcher_lib.command.get_minecraft_command(latest_version, minecraft_directory, options)

# Start Minecraft
subprocess.run(minecraft_command)

Features:

  • Easy installing
  • Get command to run Minecraft
  • Login to Microsoft account
  • Supports Forge, Fabric, Quilt and Liteloader
  • Old versions like alpha or beta supported
  • All functions have type annotations and docstrings
  • Only depents on requests
  • Supports PyPy
  • Full Documention with tutorial online available
  • Supports reading and writing profiles of the Vanilla Launcher
  • Install of mrpack modpacks
  • All public APIs are static typed
  • Examples available
  • OpenSource

View more examples

Read the documentation

Thanks to tomsik68 who documented how a minecraft launcher works

Buy me a coffe

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

minecraft_launcher_lib-6.5.tar.gz (47.6 kB view details)

Uploaded Source

Built Distribution

minecraft_launcher_lib-6.5-py3-none-any.whl (45.4 kB view details)

Uploaded Python 3

File details

Details for the file minecraft_launcher_lib-6.5.tar.gz.

File metadata

  • Download URL: minecraft_launcher_lib-6.5.tar.gz
  • Upload date:
  • Size: 47.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for minecraft_launcher_lib-6.5.tar.gz
Algorithm Hash digest
SHA256 2903fe423d9ca90027e9829d8dbc7573a7159364d74f149208a343619cacaa03
MD5 62b293ce0449b1fea0d955551b3d377f
BLAKE2b-256 9a73b099eec1dfa6f26cce27aeb60a9a1f07ff183a04ace127bb07bb66d7723d

See more details on using hashes here.

File details

Details for the file minecraft_launcher_lib-6.5-py3-none-any.whl.

File metadata

File hashes

Hashes for minecraft_launcher_lib-6.5-py3-none-any.whl
Algorithm Hash digest
SHA256 9b87545e99071209ee182fb7f6387713fec65f76a756c65fcee569165804e5d5
MD5 9c06a65d812016e639c948247d012e84
BLAKE2b-256 3e32d2991db2f002e5262cad4b38b48891566d05b88958a850ed54111e3e0772

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page