GDMC HTTP Interface Mod
适用于 Minecraft(Java 版)的模组,实现了用于读取和写入方块(以及更多功能)的 HTTP 接口。
通过此接口,你可以使用在同一台机器上运行的其他应用程序和脚本来读取和修改 Minecraft 世界。
本模组旨在作为 Minecraft 生成式设计竞赛 (GDMC) 的工具。这是一项针对 Minecraft 中过程式 AI 系统的年度竞赛,挑战在于编写一种能够适应现有地形并生成定居点的算法。欢迎加入我们的 社区 Discord 服务器!
| Minecraft version | GDMC-HTTP version | Docs | GDMC competition year |
|---|---|---|---|
| 1.21.11 | ? GDMC-HTTP 1.8.4 | ? API Docs | 2026 |
| 1.21.4 | ? GDMC-HTTP 1.6.0 | ? API Docs | 2025 |
| 1.20.2 | ? GDMC-HTTP 1.6.0 | ? API Docs | 2024 |
| 1.19.2 | ? GDMC-HTTP 1.6.0 | ? API Docs | 2023 |
| 1.16.5 | ? GDMC-HTTP 0.4.2 | ? API Docs | 2021, 2022 |
用法
当你打开一个 Minecraft 世界时,你会看到一条聊天消息,提示模组已在地址 localhost:9000 上打开了 HTTP 连接。这意味着你现在可以从外部程序向 Minecraft 发送 HTTP 请求,只要该世界处于打开状态。
对于测试和实验,我们推荐使用 API 测试工具,如 Kreya、Yaak、HTTPie,或者像 cURL 或 wget 这样的命令行工具。
如果你想构建自己的定居点生成器或其他应用程序,我们推荐使用 GDPC Python 库,这是由 GDMC 社区专门为配合此模组而开发的。但任何支持通过 HTTP 进行通信的编程语言或脚本语言(包括大多数语言,无论是内置支持还是通过易于使用的库实现)都可以使用。
HTTP 端点
当 HTTP 接口处于活动状态时,你可以访问以下 HTTP 端点:
| HTTP 方法 | URL | 描述 | 文档 |
|---|---|---|---|
POST |
/commands |
? 发送 Minecraft 控制台命令 | ? API 文档 |
GET |
/blocks |
? 获取指定区域的方块信息 | ? API 文档 |
PUT |
/blocks |
? 放置方块 | ? API 文档 |
GET |
/biomes |
?️ 获取指定区域的生物群系信息 | ? API 文档 |
GET |
/chunks |
⛏ 获取指定区域的原始区块数据 | ? API 文档 |
GET |
/structure |
?️ 从指定区域创建 NBT 结构文件 | ? API 文档 |
POST |
/structure |
?️ 将 NBT 结构文件放置到世界中 | ? API 文档 |
GET |
/entities |
? 获取指定区域的实体信息 | ? API 文档 |
PUT |
/entities |
? 召唤实体到世界中 | ? API 文档 |
PATCH |
/entities |
? 编辑世界中已存在的实体 | ? API 文档 |
DELETE |
/entities |
? 从世界中移除实体 | ? API 文档 |
GET |
/players |
? 获取指定区域的玩家信息 | ? API 文档 |
GET |
/buildarea |
? 获取当前建筑区域的信息 | ? API 文档 |
GET |
/heightmap |
?️ 获取建筑区域的高度图信息 | ? API 文档 |
OPTIONS |
/ |
? 获取当前的 Minecraft 和模组版本 | ? API 文档 |
端点的详细文档请参见 docs/Endpoints。
命令
此模组为游戏添加了以下自定义控制台命令:
| 命令 | 描述 |
|---|---|
/buildarea |
获取当前建筑区域(如果存在)。部分 端点 可使用 withinBuildArea 标志将操作限制在此区域内。 |
/buildarea set <fromX> <fromY> <fromZ> <toX> <toY> <toZ> |
将虚拟“建筑区域”设置为世界的特定区域。对于命令参数,你可以混合使用绝对坐标、局部坐标 或 相对世界坐标。 |
/buildarea set <fromX> <fromY> <fromZ> <toX> <toY> <toZ> <name> |
设置当前建筑区域,并将此数据以 <name> 为键 存储 到存档数据中,以便后续使用。 |
/buildarea load <name> |
加载之前设置的建筑区域。 |
/buildarea remove |
移除当前建筑区域。 |
/buildarea remove <name> |
移除指定 <name> 的建筑区域。 |
/buildarea tp |
传送至当前建筑区域内(如果存在)。 |
/buildarea tp <name> |
传送至之前保存的建筑区域内。 |
/buildarea list |
列出所有已保存的建筑区域。 |
/buildarea makebook |
给予玩家一本书,其中列出了所有已保存的建筑区域作为链接,点击后可传送至相应位置。 |
/buildarea makebook <author> |
创建书籍(见上文),由 <author> 署名。若省略,作者默认为 “GDMC”。 |
/gethttpport |
显示 HTTP 接口当前的端口号。 |
/sethttpport |
将 HTTP 接口的端口号重置为默认值 9000。 |
/sethttpport <number> |
更改 HTTP 接口的端口号。当默认端口 (9000) 与机器上的其他应用程序冲突时非常有用。你需要重新加载世界才能使此设置生效。 |
致谢
GDMC-HTTP 在 GDMC 社区的帮助下得到了积极开发。特别值得一提的是 Niki Gawlik,他为 Minecraft 1.16.5 创建了该模组的原始版本。本仓库是其工作的延续。对 Fabric 加载器的支持部分基于 Simon Pribylski 的 fork。支持多个加载器和 Minecraft 版本并共存于同一分支的项目结构,借鉴自 Distant Horizons 模组。
GDMC HTTP Interface Mod
Mod for Minecraft (Java Edition) that implements an HTTP interface for reading and writing blocks (and more).
With this interface you can use other applications and scripts running on the same machine to read and modify a Minecraft world.
This is designed as a tool for the Generative Design in Minecraft Competition (GDMC). This annual competition for procedural AI systems in Minecraft, where the challenge is to write an algorithm that generates a settlement while adapting to pre-existing terrain. Feel free to join our community Discord server!
| Minecraft version | GDMC-HTTP version | Docs | GDMC competition year |
|---|---|---|---|
| 1.21.11 | ? GDMC-HTTP 1.8.4 | ? API Docs | 2026 |
| 1.21.4 | ? GDMC-HTTP 1.6.0 | ? API Docs | 2025 |
| 1.20.2 | ? GDMC-HTTP 1.6.0 | ? API Docs | 2024 |
| 1.19.2 | ? GDMC-HTTP 1.6.0 | ? API Docs | 2023 |
| 1.16.5 | ? GDMC-HTTP 0.4.2 | ? API Docs | 2021, 2022 |
Usage
When you open a Minecraft world, you will see a chat message that the mod has opened an HTTP connection at the address localhost:9000. This means that you can now send HTTP requests from an external program to Minecraft while the world is open.
For testing and experimentation we recommend an API testing tool such as Kreya, Yaak, HTTPie or a command line tool such as cURL or wget.
When you want to build your own settlement generator or some other application, we recommend using the GDPC Python library, which is purpose-built by the GDMC community to work with this mod. But any programming or scripting language that supports communication over HTTP (which includes most of them, be it either built-in or via an easy-to-use library) will work.
HTTP Endpoints
When the HTTP interface is active, you have access to the following HTTP endpoints:
| HTTP method | URL | Description | Docs |
|---|---|---|---|
POST |
/commands |
? Send Minecraft console commands | ? API Docs |
GET |
/blocks |
? Get information on blocks in a given area | ? API Docs |
PUT |
/blocks |
? Place blocks | ? API Docs |
GET |
/biomes |
?️ Get information on biomes in a given area | ? API Docs |
GET |
/chunks |
⛏ Get raw chunk data in a given area | ? API Docs |
GET |
/structure |
?️ Create an NBT structure file from a given area | ? API Docs |
POST |
/structure |
?️ Place an NBT structure file into the world | ? API Docs |
GET |
/entities |
? Get information on entities in a given area | ? API Docs |
PUT |
/entities |
? Summon entities into the world | ? API Docs |
PATCH |
/entities |
? Edit entities that already exist in the world | ? API Docs |
DELETE |
/entities |
? Remove entities from the world | ? API Docs |
GET |
/players |
? Get information on players in a given area | ? API Docs |
GET |
/buildarea |
? Get information on the current build area | ? API Docs |
GET |
/heightmap |
?️ Get heightmap information of the build area | ? API Docs |
OPTIONS |
/ |
? Get current Minecraft and mod version | ? API Docs |
Detailed documentation of the endpoints can be found at docs/Endpoints.
Commands
This mod adds the following custom console commands to the game:
| Command | Description |
|---|---|
/buildarea |
Get the current build area, if present. Some endpoints can use the withinBuildArea flag to constrain actions to this area. |
/buildarea set <fromX> <fromY> <fromZ> <toX> <toY> <toZ> |
Set virtual "build area" to a certain area of the world. For the command arguments you can mix and match absolute, local or relative coordinates. |
/buildarea set <fromX> <fromY> <fromZ> <toX> <toY> <toZ> <name> |
Set the current build area and store this data under <name> with the save data for later use. |
/buildarea load <name> |
Load previously set build area. |
/buildarea remove |
Remove current build area. |
/buildarea remove <name> |
Remove build area of given <name>. |
/buildarea tp |
Teleport to within current build area, if present. |
/buildarea tp <name> |
Teleport to within previously saved build area. |
/buildarea list |
List all saved build areas. |
/buildarea makebook |
Give players a book that lists all saved build areas as links that when clicked teleport you to that location. |
/buildarea makebook <author> |
Create book (see above), signed by <author>. If omitted author defaults to "GDMC". |
/gethttpport |
Show current port number of the HTTP interface. |
/sethttpport |
Reset port number of the HTTP interface back to the default 9000. |
/sethttpport <number> |
Changes port number of the HTTP interface. Useful for when the default port (9000) conflicts with some other application on your machine. You need to reload your world for this setting to take effect. |
Acknowledgements
GDMC-HTTP has been actively developed with the help of the GDMC community. Of special note here is Niki Gawlik, who created the original version of this mod for Minecraft 1.16.5. This repo is a continuation of their work. Fabric mod loader support was in part based on a fork by Simon Pribylski. The project structure that makes it possible to support multiple mod loaders and Minecraft versions all on the same branch has been adapted from the Distant Horizons mod.
下载 GDMC HTTP Interface
下载 GDMC HTTP Interface
下载 GDMC HTTP Interface
下载 GDMC HTTP Interface
下载 GDMC HTTP Interface
下载 GDMC HTTP Interface
下载 GDMC HTTP Interface
下载 GDMC HTTP Interface
下载 GDMC HTTP Interface
下载 GDMC HTTP Interface
- 新增:所有路由现在也支持
OPTIONS方法,用于 CORS 预检请求。感谢 MoltenCoffee! - 修复:升级至稳定的 NeoForged 版本。
- 修复:升级 Fabric 加载器。
- 修复:改进 HTTP 服务器初始化的日志记录。
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
一个用于收集生物掉落物的多区块模组。
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
原版世界生成优化模组
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
查看物品与配方
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
评论 0
登录后参与评分
还没有评论,来抢沙发吧