MinecartChunkLoader
当矿车经过已加载世界的边缘时,长距离铁轨上的运行会停滞。此插件会使移动中的矿车周围的区块保持加载状态,从而让矿车自带其加载窗口。
停放的矿车不消耗资源。矿车后方的区块会自动卸载。
工作原理
每隔 scan-interval-ticks(扫描间隔刻),插件会在每个启用的世界中遍历已加载的矿车,并为每辆矿车周围的区块方块添加一个 Bukkit 插件区块票(plugin chunk ticket)。每张票都带有到期刻数,每次刷新时该刻数都会向后推移。停止刷新的票将过期,矿车后方的区块也会正常卸载。
由于持有票的区块会持续 ticking,矿车得以继续移动,进而标记下一个区块——加载窗口随矿车一同移动。
功能特性
- 仅追踪实际在移动的矿车,并配有可配置的宽限期,以便矿车在车站或岔道暂停时不会立即导致其周围区块卸载。
- 全局区块上限(
max-loaded-chunks)。达到上限时,优先服务正在使用的矿车,然后才是各矿车附近的区块——这样即使失控的漏斗矿车农场也无法耗尽你的服务器性能。
- 按世界启用/禁用列表。
- 按变体过滤——可以追踪所有矿车,或仅追踪
CHEST_MINECART,或仅追踪有乘客的矿车。
- 空服空闲——当
require-players-online 为 true 且无人在线时,跳过所有工作。
- 所有内容均在主线程通过单个重复任务运行。不进行异步 Bukkit 访问。
- 在
WorldUnloadEvent 时释放票证,因此插件永远不会阻塞世界卸载。
- 无依赖项。
命令
| 命令 |
描述 |
/mcl status |
已持有的区块、已追踪的矿车、当前设置、按世界分解统计 |
/mcl reload |
重新读取 config.yml 并重启扫描任务 |
两者均需权限 minecartchunkloader.admin(默认:op)。完整命令名为 /minecartchunkloader。
配置
plugins/MinecartChunkLoader/config.yml:
| 键 |
默认值 |
备注 |
radius |
2 |
每辆矿车的区块半径。2 = 5×5 方格 = 25 个区块。最大值为 16。 |
scan-interval-ticks |
10 |
动力矿车在 10 刻内约移动 4 格,完全处于半径 2 的方格范围内。 |
keep-alive-ticks |
100 |
最后一次刷新后,区块保持被票证锁定的时间长度。 |
require-moving |
true |
设为 false 以永久加载所有矿车周围的区块。开销较大。 |
stationary-grace-ticks |
60 |
静止的矿车仍被视为“移动”的时间长度。 |
movement-threshold |
0.05 |
两次扫描之间需要移动多少格才算作发生了位移。 |
require-occupied |
false |
仅追踪有乘客的矿车。 |
require-players-online |
true |
在空服上跳过所有工作。 |
max-loaded-chunks |
512 |
所有世界的全局上限。 |
minecart-types |
[] |
空列表表示所有变体。例如 [MINECART, CHEST_MINECART]。 |
worlds.mode / worlds.list |
allow / [] |
allow = 仅列出中的世界;deny = 除列出中的世界外的所有世界。空列表 = 所有世界。 |
debug |
false |
每次扫描时记录矿车和区块数量。 |
规模估算
最坏情况下的区块数为 活跃矿车数量 × (2 × radius + 1)²。使用默认值时,每辆矿车占用 25 个区块,因此 max-loaded-chunks: 512 可同时容纳约 20 辆矿车运行。如果你运行繁忙的铁轨网络,请提高上限或将 radius 降至 1(每辆矿车 9 个区块)。
安装
- 将 jar 文件放入服务器的
plugins/ 文件夹中。
- 重启服务器。默认配置文件将写入
plugins/MinecartChunkLoader/config.yml。
- 根据你的铁轨网络调整
radius 和 max-loaded-chunks,然后执行 /mcl reload。
兼容性
基于 Paper 26.2(paper-api:26.2.build.65-beta,Java 25)构建并测试。需要 Paper 或其分支——它使用 paper-plugin.yml 引导程序,因此不支持原版 Spigot/Bukkit。
不支持 Folia。 该插件使用单个全局重复任务,而非 Folia 的区域化调度器。
已验证行为
已在实时 Paper 26.2 服务器上测试:
- 插件成功启用,
api-version: 26.2 被接受。
- 移动的矿车获取票证(半径 2 时一辆矿车对应 25 个区块)。
- 矿车移动期间票证不断刷新,并在其停止后约
keep-alive-ticks 时间释放。
/mcl status 和 /mcl reload 在控制台和游戏内均可正常使用。
- 安全停用,所有票证均已释放。
MinecartChunkLoader
Long rail lines stall when a cart runs past the edge of the loaded world. This plugin keeps the
chunks around moving minecarts loaded, so the cart carries its own loading window with it.
Parked carts cost nothing. Chunks behind the cart unload again on their own.
How it works
Every scan-interval-ticks the plugin walks the loaded minecarts in each enabled world and adds a
Bukkit plugin chunk ticket to the square of chunks around each one. Each ticket carries an expiry
tick that is pushed forward every time it is refreshed. Tickets that stop being refreshed lapse,
and the chunks behind the cart unload normally.
Because a ticketed chunk stays ticking, the cart keeps moving, which keeps the next chunk ticketed —
the loading window travels with the cart.
Features
- Tracks only carts that are actually moving, with a configurable grace period so a cart pausing
at a station or a junction does not immediately drop its chunks.
- Global chunk cap (
max-loaded-chunks). When the cap is hit, occupied carts are served first,
then the chunks nearest each cart — so a runaway hopper-cart farm cannot eat your server.
- Per-world allow/deny list.
- Per-variant filtering — track all minecarts, or only
CHEST_MINECART, or only carts with a
passenger.
- Idles on an empty server —
require-players-online skips all work when nobody is online.
- Everything runs on the main thread in a single repeating task. No async Bukkit access.
- Tickets are released on
WorldUnloadEvent, so the plugin never blocks a world unload.
- No dependencies.
Commands
| Command |
Description |
/mcl status |
Chunks held, carts tracked, current settings, per-world breakdown |
/mcl reload |
Re-read config.yml and restart the scan task |
Both require minecartchunkloader.admin (default: op). /minecartchunkloader is the full name.
Configuration
plugins/MinecartChunkLoader/config.yml:
| Key |
Default |
Notes |
radius |
2 |
Chunk radius per cart. 2 = a 5×5 square = 25 chunks. Max 16. |
scan-interval-ticks |
10 |
A powered cart covers ~4 blocks in 10 ticks, well inside a radius-2 square. |
keep-alive-ticks |
100 |
How long a chunk stays ticketed after its last refresh. |
require-moving |
true |
Set false to keep every cart's surroundings loaded permanently. Expensive. |
stationary-grace-ticks |
60 |
How long a stopped cart still counts as moving. |
movement-threshold |
0.05 |
Blocks of travel between scans needed to count as movement. |
require-occupied |
false |
Only track carts with a passenger. |
require-players-online |
true |
Skip all work on an empty server. |
max-loaded-chunks |
512 |
Global cap across all worlds. |
minecart-types |
[] |
Empty = all variants. e.g. [MINECART, CHEST_MINECART]. |
worlds.mode / worlds.list |
allow / [] |
allow = only listed worlds, deny = all but listed. Empty list = every world. |
debug |
false |
Logs cart and chunk counts every scan. |
Sizing it
Worst case is active carts × (2 × radius + 1)² chunks. At the defaults that is 25 chunks per cart,
so max-loaded-chunks: 512 covers about 20 carts moving at once. Raise the cap, or drop radius
to 1 (9 chunks per cart), if you run a busy rail network.
Installation
- Drop the jar into your server's
plugins/ folder.
- Restart. The default config is written to
plugins/MinecartChunkLoader/config.yml.
- Tune
radius and max-loaded-chunks to your rail network, then /mcl reload.
Compatibility
Built and tested against Paper 26.2 (paper-api:26.2.build.65-beta, Java 25). Requires Paper or
a Paper fork — it uses the paper-plugin.yml bootstrap, so plain Spigot/Bukkit is not supported.
Folia is not supported. The plugin uses a single global repeating task rather than Folia's
regionised scheduler.
Verified behaviour
Tested on a live Paper 26.2 server:
- Plugin enables cleanly,
api-version: 26.2 accepted.
- Moving carts acquire tickets (25 chunks for one cart at radius 2).
- Tickets refresh while the cart moves and are released ~
keep-alive-ticks after it stops.
/mcl status and /mcl reload work from console and in-game.
- Clean disable with all tickets released.
评论 0
登录后参与评分
还没有评论,来抢沙发吧