Skip to main content

A minecraft launcher core library for python

Project description

pmccc

关于

这是一个基于pythonMinecraft启动器核心

示例

启动器信息

import pmccc

launcher_info = pmccc.launcher_info("启动器名称", "启动器版本")

玩家信息

import pmccc

# 离线登录(可自定义UUID)
player = pmccc.player.player_base()
player.name = "名称"
player.uuid = "UUID"

print(player)

# 离线登录
player = pmccc.player.player_offline("名称")

print(player)

# 微软登录
player = pmccc.player_online()

url = input(f"请访问地址: {player.login_url()}\n把跳转后的链接粘贴过来\n>")
# microsoft_refresh_token 若90天不使用就会过期,一定不能泄露
microsoft_refresh_token = player.login_auto_init(url)

print(player)

# 以后改用 login_auto 登录即可
player.login_auto(microsoft_refresh_token)

# 可使用 get_profile 获取玩家档案
print(player.get_profile(player.access_token))

获取Java

import pmccc

java_manager = pmccc.java_manager()
# 会通过环境变量寻找可用Java
java_manager.search()

print(java_manager)

版本文件

import pmccc
import json

with open("xxx.json", encoding="utf-8") as fp:
    version = pmccc.version(json.load(fp))

# 游戏jvm与游戏参数
jvm, game = version.get_args()

# 获取库(注意这里返回的是相对路径,绝对路径需要你自行拼接)
library = version.get_library()
native = version.get_native()

# 获取classpath
class_path = version.merge_cp(library, "游戏jar文件路径")

# 获取启动参数
args = version.replace_args(
    launcher_info,
    java_manager,  # 这里会自动选择合适Java版本
    version.merge_args(jvm, game),
    class_path,
    player,
    "游戏目录(版本文件夹)",
    "asset目录",
    "natives目录"
)

解压native

import pmccc

# 清理目录
pmccc.native.clear("natives目录")

# 注意刚刚说的,这里native默认是相对路径,记得自行拼接
pmccc.native.unzip_all(native)

启动游戏

import subprocess

subprocess.run(args, cwd="游戏目录")

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pmccc-0.2.6-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file pmccc-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: pmccc-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pmccc-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 bc4aaf62188c98ffe340a9158c16d9d5f73b209b30ae5d33bff4d0405528aa2a
MD5 cffce816b0dc414fdf5925136b16e6b6
BLAKE2b-256 73d5bc28842494f737ee4debc9dc287ed44228335e60c4c0f37052c6453f3b98

See more details on using hashes here.

Provenance

The following attestation bundles were made for pmccc-0.2.6-py3-none-any.whl:

Publisher: build.yml on cueavyqwp/pmccc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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