此模组为 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)
评论 0
登录后参与评分
还没有评论,来抢沙发吧