此模组为 Create 列车的位置数据提供了一个端点。安装方法很简单,只需将 jar 文件放入 mods 文件夹即可。默认情况下使用端口 8080,这可以在配置文件中更改。
BlueMap 覆盖层
要在地图上显示列车、轨道、车站、信号和传送门,请将 train.js 复制到 BlueMap 的 webroot(例如 bluemap/web/),将文件顶部的 host 设置为从浏览器视角看到的此 API 的地址,并将其添加到 BlueMap 的 webapp.conf 中的 scripts 里:
scripts: [
"./train.js"
]
点击列车会显示其速度、目的地、时刻表和货物;点击车站会显示下一班到达的列车;点击传送门会跳转到另一个维度的地图。如果 BlueMap 通过 https 提供服务,则 API 也必须可通过 https 访问(浏览器会阻止混合内容)。
当与 一起使用时,也可以在配置中配置列车模型的路径。
端点
| 路径 | 内容 |
|---|---|
/network |
节点、边(含长度、材质、网络 ID、信号块区段)、车站、信号、网络(含 Create 的颜色)以及传送门节点对。每 5 秒更新一次。 |
/trains, /trainsLive (SSE, 200 ms) |
包含位置、速度、目的地、时刻表、路线、所有者、乘客的列车信息。 |
/status, /statusLive (SSE, 1 s) |
占用和预留的信号块、信号状态,以及每个车站在站台上的列车、即将到达的列车和下一班到达的列车。 |
/cargo?train=<id> |
每节车厢的物品和流体(按需计算)。 |
/features |
配置中启用了哪些可选数据(见下文)。 |
/trainModels/… |
来自 trainModelPath 的列车模型。 |
所有数据均从服务器线程上的 Create 读取并缓存,因此请求永远不会直接触及游戏状态。
示例配置:
#Webserver Port
# Default: 8080
# Range: 1 ~ 65535
serverPort = 8080
#Webserver hostname
serverHost = "0.0.0.0"
#Path of the train models
trainModelPath = "bluemap/train_models/"
可选数据
配置中的 [data] 部分用于开启或关闭可选信息。禁用的数据完全不会收集,在响应中为 null;/features 报告当前的开关状态,BlueMap 覆盖层也会隐藏任何被禁用的数据。位置、轨道和车站始终包含在内。
[data]
owner = true # 列车所有者(uuid 和玩家名称)
trainStatus = true # 速度、最大速度、是否脱轨
passengers = true # 车上玩家数量
navigation = true # 目的地、距离、是否在信号前等待
schedule = true # 时刻表标题、当前停靠站、状态、等待原因
route = true # 前往目的地的计划路线
stationArrivals = true # 按车站:站台上的列车、即将到达的列车、下一班到达的列车
signals = true # 信号、信号状态及占用的信号块
portals = true # 通过传送门链接的轨道节点
cargo = true # 列车库存和储罐 (/cargo)
This mod adds an endpoint for the postion data of the create trains. To install simply place the jar file into the mods folder. By default it uses port 8080, this can be changed in the config file.
BlueMap overlay
To show trains, tracks, stations, signals and portals on the map, copy train.js into BlueMap's webroot (e.g. bluemap/web/), set host at the top of the file to the address of this API as seen from the browser, and add it to the scripts in BlueMap's webapp.conf:
scripts: [
"./train.js"
]
Clicking a train shows its speed, destination, schedule and cargo; clicking a station shows the next arrivals; clicking a portal jumps to the map of the other dimension. If BlueMap is served over https, the API must be reachable over https as well (browsers block mixed content).
When used together with the path to the train models can be configured in the config aswell.
Endpoints
| Path | Content |
|---|---|
/network |
Nodes, edges (with length, material, network id, signal block sections), stations, signals, networks (with Create's colour) and portal node pairs. Updated every 5 s. |
/trains, /trainsLive (SSE, 200 ms) |
Trains with position, speed, destination, schedule, route, owner, passengers. |
/status, /statusLive (SSE, 1 s) |
Occupied and reserved signal blocks, signal states, and per station the train at the platform, the arriving train and the next arrivals. |
/cargo?train=<id> |
Items and fluids per carriage (computed on request). |
/features |
Which optional data is enabled in the config (see below). |
/trainModels/… |
Train models from trainModelPath. |
All data is read from Create on the server thread and cached, so requests never touch the game state directly.
Example config:
#Webserver Port
# Default: 8080
# Range: 1 ~ 65535
serverPort = 8080
#Webserver hostname
serverHost = "0.0.0.0"
#Path of the train models
trainModelPath = "bluemap/train_models/"
Optional data
The [data] section of the config turns optional information on or off. Disabled data is not collected at all and is null in the answers; /features reports the current switches, and the BlueMap overlay hides whatever is disabled. Positions, tracks and stations are always included.
[data]
owner = true # train owner (uuid and player name)
trainStatus = true # speed, max speed, derailed
passengers = true # number of players on board
navigation = true # destination, distance to it, waiting at a signal
schedule = true # schedule title, current stop, state, wait reason
route = true # planned route to the destination
stationArrivals = true # per station: train at the platform, arriving train, next arrivals
signals = true # signals, signal states and occupied signal blocks
portals = true # track nodes linked through portals
cargo = true # train inventories and tanks (/cargo)
下载 CreateTrainWebAPI
下载 CreateTrainWebAPI
下载 CreateTrainWebAPI
下载 CreateTrainWebAPI
下载 CreateTrainWebAPI
下载 CreateTrainWebAPI
下载 CreateTrainWebAPI
下载 CreateTrainWebAPI
Create Train Web API 1.1.0
亮点
- 更丰富的列车信息:速度、目的地、时刻表、乘客、所有者等
- 实时信号状态、占用信号区段以及各站点的即将到站信息
- 按需获取列车货物数据
- 配置开关可控制 API 收集并返回哪些信息
- BlueMap 覆盖层 (
train.js) 现已移至本仓库,并支持点击列车、站点和传送门
新增内容
API
/trains和/trainsLive现在包含速度、目标速度、最大速度、脱轨状态、乘客数量、所有者名称、列车图标、Create 的颜色索引、网络 ID、导航信息(目的地、距离、在信号前等待)、时刻表(标题、当前停靠站、状态、暂停/已完成、等待原因)以及计划路线。/network现在包含每个网络及其由 Create 分配的颜色、节点/边/站点上的网络 ID、每条边的轨道长度与材质、信号机、每条边的信号区段,以及通过传送门连接的节点对。/status和/statusLive(新增,每秒更新一次):占用的和预留的信号区段、信号状态,以及每个站台上正在停靠的列车、即将到达的列车和下一次到站信息。到站时间来自 Create 显示屏所使用的相同预测;Create 每 5 秒更新一次这些时间。/cargo?train=<id>(新增):按车厢列出的物品和流体,仅在请求时计算。/features(新增):启用了哪些可选数据(见下文)。
配置:可选数据
新增 [data] 部分用于开启或关闭可选信息:owner(所有者)、trainStatus(列车状态)、passengers(乘客)、navigation(导航)、schedule(时刻表)、route(路线)、stationArrivals(站点到站)、signals(信号)、portals(传送门)、cargo(货物)。默认情况下全部开启。禁用后这些数据将完全不被收集,从而减轻服务器负担,并在响应中显示为 null。更改无需重启即可生效。
- NeoForge / Forge:
config/createtrainwebapi-common.toml - Fabric:
config/createtrainwebapi.toml(不含该部分的现有文件会保持所有选项开启)
BlueMap 覆盖层
- 点击 列车 可查看其速度(方块/秒)、目的地和距离、信号等待时间、时刻表、乘客和货物。
- 点击 站点 可查看站台上的列车及带有倒计时的下一次到站列车。
- 点击 传送门 可跳转至传送门所在位置的另一个维度的地图。
- 新增图层:站点与传送门、信号灯、占用信号区段。
- 轨道以 Create 为每个网络指定的颜色绘制。
- 菜单项现变为可切换状态的开关,并会在浏览器中记住状态。默认情况下,“穿过地形的列车”和轨道线是关闭的。
- 任何在 API 配置中禁用的内容都会自动隐藏。
变更
- 所有数据现在均从 Create 在服务端线程读取并进行缓存(列车数据每 200 毫秒更新一次,状态数据每秒更新一次,网络数据每 5 秒更新一次)。请求不再直接触及游戏状态,从而避免了在服务器修改数据时读取 Create 数据可能导致的错误。
- 现有的 JSON 字段保持不变;新数据作为附加内容添加,因此现有客户端仍可正常工作。
修复
stopped(已停止)和backwards(反向)始终为false的问题已修复。- 列车名称原本显示为
literal{…}格式,现已修正为纯文本名称。 - 单个车厢缺失数据不再导致整个
/trains响应出错。 - 覆盖层:当列车穿越传送门时,其车厢可能会显示错误的模型或位置,此问题已修复。
升级指南
覆盖层脚本已从 BluemapCreateEntityAddon 移至本仓库,且 API 不再提供该脚本服务:
- 将 train.js 复制到 BlueMap 的 webroot 目录(例如
bluemap/web/)。 - 在文件顶部设置
host为从浏览器视角看到的 API 地址。如果 BlueMap 通过 https 提供服务,则 API 也必须可通过 https 访问。 - 在 BlueMap 的
webapp.conf中将"./train.js"添加到scripts列表中。
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
查看物品与配方
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
添加区块认领和玩家组队功能,并与 Xaero's Minimap 和 World Map 集成
模组
添加全屏世界地图,显示你在世界中已探索的区域。与 Xaero's Minimap 搭配使用效果极佳。
评论 0
登录后参与评分
还没有评论,来抢沙发吧