pyCraft
Minecraft Python 客户端库!
本项目旨在成为一个现代化的、兼容 Python 3 的、文档完善的库,用于与 Minecraft 服务器进行通信。
开发者详细信息请参阅:<http://pycraft.readthedocs.org/en/latest/>
Because66666 接手该项目后,通过参考开源库
使用Kimi-K3模型完成原代码仓库的协议升级。
仓库地址:Because66666/pyCraft
使用
pip install pycraft-minecraft
即可安装。
start.py 是一个使用该库的无头客户端(headless client)基础示例,使用 start.py --help 查看选项。
详细的使用教程与示例请参见:教程示例。
完整的使用示例仓库代码:Because66666/mc_bot_5
支持的 Minecraft 版本
pyCraft 兼容以下 Minecraft 正式版本:
- 1.8, 1.8.1, 1.8.2, 1.8.3, 1.8.4, 1.8.5, 1.8.6, 1.8.7, 1.8.8, 1.8.9
- 1.9, 1.9.1, 1.9.2, 1.9.3, 1.9.4
- 1.10, 1.10.1, 1.10.2
- 1.11, 1.11.1, 1.11.2
- 1.12, 1.12.1, 1.12.2
- 1.13, 1.13.1, 1.13.2
- 1.14, 1.14.1, 1.14.2, 1.14.3, 1.14.4
- 1.15, 1.15.1, 1.15.2
- 1.16, 1.16.1, 1.16.2, 1.16.3, 1.16.4, 1.16.5
- 1.17, 1.17.1
- 1.18, 1.18.1, 1.18.2
- 1.19, 1.19.1, 1.19.2, 1.19.3, 1.19.4
- 1.20, 1.20.1, 1.20.2, 1.20.3, 1.20.4, 1.20.5, 1.20.6
- 1.21, 1.21.1, 1.21.2, 1.21.3, 1.21.4, 1.21.5, 1.21.6, 1.21.7, 1.21.8, 1.21.9, 1.21.10, 1.21.11
- 26.1, 26.1.1, 26.1.2
此外,还支持部分开发快照(snapshot)和预发布版本。
minecraft/__init__.py 中包含完整的受支持 Minecraft 版本列表及对应的协议版本号。
支持的功能
虽然 pyCraft 可以兼容任何受支持的服务器,但目前库中仅实现了解码/编码全部数据包中的一个子集:保持服务器连接所必需的数据包、用于聊天的数据包,以及其他一些数据包。
请注意,聊天消息签名(Minecraft 1.19 引入)已支持:当认证令牌带有聊天签名证书时(MicrosoftAuthenticationToken 在 authenticate() 时传入 fetch_certificates=True),发出的聊天消息会自动签名,因此设置了 enforce-secure-chat=true 的服务器也能正常聊天。未获取证书时,聊天消息仍以未签名方式发送,适用于离线模式(offline-mode)服务器和不强制安全聊天的服务器。
服务器资源包(resource pack)已支持:对于 configuration 状态(协议 764 及以后)和 play 状态下服务器下发的 resource pack send / add resource pack 数据包,客户端会自动应答,按"已接受 → 已下载 → 已加载"的顺序回报,但不会真正下载资源包内容。这样,强制要求资源包、且要等到客户端应答后才结束 configuration 状态的服务器,既不会把客户端踢下线,也不会让连接永久卡在 configuration 阶段。
该默认行为可按需替换:向 Connection 传入 handle_resource_pack 参数即可,回调会拿到资源包数据包(含 url / hash / forced,协议 765 及以后还有 uuid),可以改为拒绝(Result.DECLINED)、自行下载,或返回 None 表示完全由用户处理。详见 Connection 类的文档字符串。
希望使用其他功能的开发者可以通过以下方式贡献代码:为所需的数据包实现数据包类,将它们添加到 minecraft/networking/packets 目录下,并提交 Pull Request。
支持的 Python 版本
pyCraft 兼容(至少)以下 Python 实现:
- Python 3.5
- Python 3.6
- Python 3.7
- Python 3.8
- Python 3.9
- PyPy
依赖要求
这些依赖也记录在 setup.py 中。
cryptography 库的安装说明请参阅:<https://cryptography.io/en/latest/installation/>,
基本上执行 pip install -r requirements.txt 即可安装所有依赖。
联系方式
本项目目前由 Because66666 进行维护,继承项目:ammaraskar/pyCraft。
GitHub
首选的沟通方式是通过本项目的 GitHub 页面。
邮件
可以通过邮件联系:
- Because66666 z66666z@163.com
Metadata
Release files for pycraft-minecraft 0.7.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pycraft_minecraft-0.7.4.tar.gz | 143.1 kB | Without provenance | Details for pycraft_minecraft-0.7.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pycraft_minecraft-0.7.4-py3-none-any.whl | Python 3 | none | any | Details for pycraft_minecraft-0.7.4-py3-none-any.whl |
Total release size: 246.7 kB
Release files / pycraft_minecraft-0.7.4.tar.gz
| Download URL | pycraft_minecraft-0.7.4.tar.gz |
|---|---|
| Size | 143.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
88127d51b9f2d143ce255796083621b844e19372fce4c49847c2a90b89d0480a
|
|
BLAKE2b-256 checksum How to use checksums |
2e7c68c31e76b5c79f226bf4597e430a940b177165d6ad3c3831467a3703b2a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.9
|
Release files / pycraft_minecraft-0.7.4-py3-none-any.whl
| Download URL | pycraft_minecraft-0.7.4-py3-none-any.whl |
|---|---|
| Size | 103.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
891a456922b87553f211ff26209ddfa18d08e01dfa716f30bd8eef02df348470
|
|
BLAKE2b-256 checksum How to use checksums |
a19d48900cd5d17235126521f948072cd7ae314a73a1f7915da2285b7deff0e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.9
|
Security for pycraft-minecraft 0.7.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.