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.9.0.79713.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.9.0.79713-py3-none-any.whl (262.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bg_mc_sdk-3.9.0.79713.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.9.0.79713.tar.gz
Algorithm Hash digest
SHA256 bf356060cd6a6c79e97ef011462ed33effddcca88c9c174bc43a259a1aa6ced6
MD5 76b5b17f877967143ac4cac1a23d71cc
BLAKE2b-256 90f989ce3fab9cea0822229f936ddf6869a974580751a767de551b5f20765110

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bg_mc_sdk-3.9.0.79713-py3-none-any.whl
  • Upload date:
  • Size: 262.4 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.9.0.79713-py3-none-any.whl
Algorithm Hash digest
SHA256 2d7ce31edb61f76022c27ace95ed1f4226ec49eaf8a89875dbb2ae27f1f7d665
MD5 895020009322c5c886cdbe2d015f3b31
BLAKE2b-256 53f7ee367749963fdbcd1cdeb16c610501cd42e810780fc65b223feefd8e420d

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