Integrated REST模组允许玩家通过REST API来读写集成动力网络。
该模组仅添加了一个方块——HTTP代理器,玩家可以通过搭建web服务端来控制集成动力网络,以实现非常复杂的自动化控制或是一些高级功能。
有关此模组可能实现的一些例子(以及一些外部编码):
- 根据您的Minecraft世界中的白天时间来控制您房间的灯光。
- 收到电子邮件后,在Minecraft中播放音乐或音效。
- 在您的网站上显示全球所有在线玩家的位置。
- Twitch或Mixer获得新的订阅者后,打开一扇门。
游戏启动后,会在本地开放3000端口(可配置)以接收HTTP请求,GET请求用于获取集成动力网络和组件的信息,POST请求用于修改HTTP代理器的值;
若想获取某个组件的信息,例如ID为44,通过GET请求 http://localhost:3000/networkElement/integrateddynamics/part/44,获取到的内容为JSON格式的信息:
{ "@context": "https://raw.githubusercontent.com/CyclopsMC/IntegratedREST/master-1.12/src/main/resources/context.jsonld", "@id": "http://localhost:3000/", "networkElements": [ { "@id": "http://localhost:3000/networkElement/integrateddynamics/part/44", "position": { "world": 0, "x": -26, "y": 57, "z": -249, "side": "ir:east" }, "block": "http://localhost:3000/registry/block/integrateddynamics/cable", "@type": [ "NetworkElement", "http://localhost:3000/registry/part/display_panel" ], "channel": 0, "priority": 0, "updateInterval": 1, "network": "http://localhost:3000/network/1619976862", "valueType": "http://localhost:3000/registry/value/valuetype/valuetypes/integrateddynamics/string/name", "value": "I was updated\nvia HTTP!", "target": { "world": 0, "x": -25, "y": 57, "z": -249, "side": "ir:west" }, "loaded": true }, ... ] }
事实上这JSON属于JSON-LD(Linked Data JSON,一种链接数据格式),通过继续访问JSON-LD中的链接可获取更多的信息。
想要修改一个HTTP代理器的值,例如其ID为7,可通过POST请求 http://localhost:3000/networkElement/integrateddynamics/http/7;
具体能修改的数据类型与对应的方法请查看https://github.com/CyclopsMC/IntegratedREST/wiki/HTTP-POST-requests
该模组无法通过HTTP请求直接获取变量卡箱里的变量卡值,可将变量卡放入显示器、固值器中,再通过获取这些组件的信息获取变量值。
下载地址 |
CurseForge |
GitHub |