Skip to main content

一个用于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)、给 NativeScreenManagerinstance() 等官方 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


Download files

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

Source Distribution

bg_mc_sdk-3.8.0.75813.tar.gz (168.8 kB view details)

Uploaded Source

Built Distribution

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

bg_mc_sdk-3.8.0.75813-py3-none-any.whl (262.7 kB view details)

Uploaded Python 3

File details

Details for the file bg_mc_sdk-3.8.0.75813.tar.gz.

File metadata

  • Download URL: bg_mc_sdk-3.8.0.75813.tar.gz
  • Upload date:
  • Size: 168.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for bg_mc_sdk-3.8.0.75813.tar.gz
Algorithm Hash digest
SHA256 4a8e26ef95d0cbb23108ba43fea91d3ee1dab326f8a0aa79e4beb7fa11cf5721
MD5 0392f5aa54b605e4104410104bac4383
BLAKE2b-256 3f9826e7d3504e2c8f22df43ae251aee8047511d53b7c301dfd7884402fe25b0

See more details on using hashes here.

File details

Details for the file bg_mc_sdk-3.8.0.75813-py3-none-any.whl.

File metadata

  • Download URL: bg_mc_sdk-3.8.0.75813-py3-none-any.whl
  • Upload date:
  • Size: 262.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for bg_mc_sdk-3.8.0.75813-py3-none-any.whl
Algorithm Hash digest
SHA256 acb4e3d54f05db63b7d38b204cd7e1a0796078aa3527f6e5fb9607d834927488
MD5 d2fd941bd6a389cf1c50ba77f7889e3b
BLAKE2b-256 f395b010f987336dcf9c6b6357cb9ac92c746ffaaf36d0b33e7c8c4eb53f91d3

See more details on using hashes here.

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