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
- 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-4.4.tar.gz
(17.3 kB
view hashes)
Built Distribution
Close
Hashes for minecraft-launcher-lib-4.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 229a095324bf9036d4efc4086af157ed7e54363eedba13717aa2aa2a811297d5 |
|
MD5 | 186783164cda3c9ab18b030277df3a24 |
|
BLAKE2b-256 | c305084daeac109ea345c2033623f8e9c3b6637acdc4fc9eb57ad93df9a0b69a |
Close
Hashes for minecraft_launcher_lib-4.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7d19f5ef9e4b0b713daefee9c98d376d35b8cf441b25cfc3e1e3f5668bd2c77 |
|
MD5 | 096c2039ee8d85f80d6f83de22384504 |
|
BLAKE2b-256 | 76dcf7b9e4bbca97d8509d77cc9e12afe7ad0df305d5f882b6c98b560dc8d23f |