A library for creating a custom Minecraft launcher
Project description
minecraft-launcher-lib
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"
SECRET = "YOUR SECRET"
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
print(f"Please open {minecraft_launcher_lib.microsoft_account.get_login_url(CLIENT_ID, REDIRECT_URL)} in your browser and copy the url you are redirected into the prompt below.")
code_url = input()
# Check if the url contains a code
if not minecraft_launcher_lib.microsoft_account.url_contains_auth_code(code_url):
print("The url is not valid")
sys.exit(1)
# Get the code from the url
auth_code = minecraft_launcher_lib.microsoft_account.get_auth_code_from_url(code_url)
# Get the login data
login_data = minecraft_launcher_lib.microsoft_account.complete_login(CLIENT_ID, SECRET, REDIRECT_URL, auth_code)
# 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.call(minecraft_command)
Features:
- Easy installing
- Get command to run Minecraft
- Login to Microsoft account
- Support Forge, Fabric 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
- All public APIs are static typed
- Examples available
- OpenSource
Thanks to tomsik68 who documented how a minecraft launcher works
Project details
Release history Release notifications | RSS feed
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-5.1.tar.gz
(19.9 kB
view hashes)
Built Distribution
Close
Hashes for minecraft-launcher-lib-5.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9243b384d13de4ec121f95d141d8a14fd521b005232d739f1abfd8d05a3274e8 |
|
MD5 | 6f08bcf6d4932152f1e55a66c4d7b3bf |
|
BLAKE2b-256 | f3bcd6267bb797a7f5b078f55008e5ab83c62e424e597407e99bef1efe90a9e2 |
Close
Hashes for minecraft_launcher_lib-5.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3073c5d6e77334e5960222af749d3c3238d1a5493ec32371ed7dd5b6b66c9396 |
|
MD5 | 0d08e079714444b39aa48266c72ce978 |
|
BLAKE2b-256 | 3add21022b92da5e71b39896500607974b4eac8c6c0b3fdff1875a91ee349ecd |