一个用于python3的mc_sdk补全库
Project description
bg_mc_sdk
网易我的世界 ModSDK(
mc-netease-sdk)的 Python 3 补全库——让你在 PyCharm 等现代 IDE 里写网易 Mod 时,拥有完整的类型提示、跳转和自动补全。
这是什么 / 为什么需要它
网易官方的 mc-netease-sdk 是为 Python 2.7 运行环境打包的,它的存根(stub)有几个问题,导致在 Python 3 的 IDE 里开发体验很差:
- 返回类型写成带引号的前向引用(
# type: () -> 'Type[BaseComponent]'),PyCharm 无法解析,点不动、补不全; - 部分类缺少关键方法签名(如
ScreenNode.__init__、NativeScreenManager.instance()),调用时 IDE 报参数不匹配或识别不出返回类型; - 直接
pip install mc-netease-sdk在 Python 3 环境会因py2-none-any标记被判为不兼容。
bg_mc_sdk 把官方 SDK 自动加工成 Python 3 友好的纯补全库:去掉返回类型引号、补齐缺失签名、剔除打包元数据,让你在 IDE 里获得和官方 API 一致、且能正常跳转/补全的开发体验。
⚠️ 本库仅用于开发期的代码补全与类型提示,不包含任何引擎实现,不能在运行时替代游戏内的真实 SDK。真正的逻辑仍由网易客户端在 Mod 运行时提供。
安装
pip install bg_mc_sdk
在 IDE 中使用
安装后,照常按官方写法 import 即可,IDE 会自动识别类型:
import mod.server.extraServerApi as serverApi
import mod.client.extraClientApi as clientApi
from mod.common.minecraftEnum import AttrType
# 此时 PyCharm 能正确补全 / 跳转 / 显示返回类型
comp = serverApi.GetEngineCompFactory().CreateAttr(player_id)
comp.GetAttrValue(AttrType.HEALTH)
相比官方 SDK 做了哪些处理
| 处理 | 说明 |
|---|---|
| 去返回类型引号 | -> 'Xxx' → -> Xxx,PyCharm 才能解析返回类型、支持链式补全 |
| 补缺失签名 | 给 ScreenNode 补 __init__(self, namespace, name, param)、给 NativeScreenManager 补 instance() 等官方 stub 遗漏的方法 |
| 剔除打包元数据 | 移除 whl 自带的 *.dist-info,只保留纯源码 stub |
| 版本号同步 | sdk/bg/__init__.py 的 __version__ 跟随官方 SDK 版本 |
自动更新机制
auto_script/ 下是一套自动维护脚本,定期把官方新版 SDK 同步过来:
检测 PyPI 新版 → 下载官方 whl → 解压 → 去 dist-info → 去返回类型引号
→ 补缺失签名(ScreenNode / NativeScreenManager ...) → 覆盖 sdk/
→ 同步 bg 版本号 → 自动 commit & push
发现新的缺失签名时,只需把对应补丁加进 update_sdk.py 的处理链(幂等),下次更新会自动应用、不会被官方内容覆盖冲掉。
版本号
版本号直接跟随网易官方 SDK,形如 3.8.0.75809,方便对照官方版本。
致谢与许可
- 本库的 stub 内容来源于网易官方
mc-netease-sdk,其以 MIT 协议开源;bg_mc_sdk在此基础上做 Python 3 适配加工,同样以 MIT 协议发布,并保留原作者版权声明。 - 项目地址:https://github.com/cluom/bg_mc_sdk
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bg_mc_sdk-3.9.0.79713.1.tar.gz.
File metadata
- Download URL: bg_mc_sdk-3.9.0.79713.1.tar.gz
- Upload date:
- Size: 169.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24b6b2e0c62f902af5c8c1bef9e5a7aecee90daeaabdaf8bccdb5e94f6f776c7
|
|
| MD5 |
6dfc64392eab867f13d1f1b39ceeac5a
|
|
| BLAKE2b-256 |
20be2295b97bd4ec2b62e78dedea55947dbe1d8d86ea110e6d7ff25c37d18c45
|
File details
Details for the file bg_mc_sdk-3.9.0.79713.1-py3-none-any.whl.
File metadata
- Download URL: bg_mc_sdk-3.9.0.79713.1-py3-none-any.whl
- Upload date:
- Size: 263.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b858d519338e36784b40b0d1c2cbe9b7b48707c7a222b8c5b70bcb3ed939958
|
|
| MD5 |
b3d7ef196d56bfa612cadd6ffb987b5f
|
|
| BLAKE2b-256 |
d1c921fe9ed418cea913e4969080245806331c2b191383097eed9a6da4f8e204
|