Pathwright
适用于 Minecraft 26.1.2 的生物寻路优化。
Pathwright 针对 Minecraft 服务器循环中最昂贵的热点之一:生物寻路。每个想要移动的生物都必须计算一条路径——而在原版中,所有这些计算都在主服务器线程上依次进行。Pathwright 用三层优化系统取代了这种做法。每一层都可以独立开关,因此如果某个功能与其他模组冲突,你只需在配置文件中添加一行即可禁用它。
简介
Pathwright 模组通过更智能地计算路径来加快生物寻路速度。与在主线程上每刻重新计算所有生物的路径不同,Pathwright 会缓存已计算过的路径,将路径更新卸载到后台线程,并降低远离玩家生物的路径重算频率。这有助于保持更高的 TPS(每秒刻数)和更短的服务器循环时间。该模组在拥有大量生物的服务器上尤为有益——例如生物农场、繁殖器或大型群体 AI——但在单人游戏和本地托管的世界中也能带来显著改善,因为在这种情况下服务器和客户端共享同一颗 CPU。
性能提升
TPS(服务器每秒刻数)
Pathwright 的优化完全运行在服务器端。TPS 的提升取决于加载且正在主动寻路的生物数量:
预计 TPS 提升:
- +1 – 3 TPS:在拥有正常生物数量的典型生存世界中
- +3 – 8 TPS:在生物农场、繁殖器或拥有 100+ 个活跃寻路生物的服务器上
- 生物离玩家越远,提升越大(LOD 系统生效时)
FPS(客户端每秒帧数)
注意!
只有当服务器/世界与客户端运行在同一台计算机上时(例如在你的 PC 上为朋友和你自己托管本地服务器,或游玩单人游戏),才能看到 FPS 的提升。如果将该模组安装在外部托管的服务器上,你会体验到服务器运行更流畅,而不是你的客户端获得更高的 FPS。
当服务器和客户端共享同一颗 CPU 时:
1. 减少服务器卡顿尖峰 → 更平滑的动画插值
当服务器错过一帧(低于 20 TPS)时,客户端会对实体位置进行错误的插值。橡皮筋效应(rubber-banding)和卡顿都源于服务器延迟。Pathwright 能让服务器更稳定地保持在 20 TPS,即使你的 GPU FPS 没有变化,客户端也会感受到明显更平滑的移动效果。
2. 单人游戏 / 集成服务器
服务器刻中节省的每一毫秒都会返还给渲染线程。在拥有生物的典型生存世界中:
- 异步寻路将路径计算完全移出主线程
- LOD 节流消除了对你看不到的生物进行的冗余计算
预计单人游戏 FPS 提升:基准 60 FPS 下 +2 – 8 FPS;在生物密集的世界、生物农场或村民繁殖器中会有更高的提升。
各项优化工作原理
异步寻路 (Async Pathfinding)
在原版中,当生物需要新路径时——比如僵尸追逐你,或村民回家——整个路径计算都在主服务器线程上运行。这会阻塞其他一切操作直到计算完成。在一个有数十只生物同时尝试重新计算路径的世界中,这种堆积会迅速发生。
Pathwright 将路径更新卸载到一个小规模的后台线程池中。当生物已有活动路径且需要重新计算时(例如你移动了位置,它需要重新规划路线),计算会在主线程之外进行,结果将在下一刻应用。新路径——即生物完全没有路径且需要开始移动的情况——仍同步计算,以便生物能立即开始移动而没有任何延迟。
战斗中的生物始终使用同步寻路。异步仅用于常规移动更新。
路径结果缓存 (Path Result Caching)
同一区域的许多生物经常走相同的路线——例如村民在同个工作站和床之间行走。Pathwright 会缓存已完成路径计算的结果。如果另一只生物需要在相同的世界状态下从相同的位置前往相同的目的地,它将复用已计算好的路径,而不是从头重新计算。
当方块发生变化时(如一扇门打开,或一面墙被放置),缓存会自动失效,以确保缓存的路径不会过时。通往移动目标(如玩家或其他生物)的路径永远不会被缓存——因为这些目标每刻都在变化。
寻路 LOD(细节层次)
在玩家附近,生物需要准确且频繁更新的寻路。在远离玩家的地方,生物每刻更新一次路径还是每 15 刻更新一次路径,实际上并无区别——你也看不到差异。Pathwright 利用了这一洞察:距离任何玩家超过 48 格的生物,其路径重算频率仅为每 15 刻一次,而非每刻一次。
无论距离多远,处于战斗状态、最近受过伤害或没有活动路径的生物都不会受到节流限制。LOD 仅影响那些已经在前往某处的生物上的常规移动更新。
配置
config/pathwright.json —— 首次启动时自动创建,带有安全默认值:
{
"enablePathCaching": true,
"pathCacheSize": 1024,
"pathCacheExpiryTicks": 200,
"enableLOD": true,
"lodDistance": 48.0,
"lodTickInterval": 15,
"enableAsync": true,
"asyncThreadCount": 2
}
所有三个模块均可独立开关。asyncThreadCount 默认为 2 —— 在拥有大量生物的服务器上增加此数值会有帮助,但不要将其设置得高于你的 CPU 核心数减 1。
常见问题 — 只是我在回答自己的问题哈哈
这会改变我的生物农场的工作方式吗?
不会。生物行为、攻击 AI、繁殖以及所有游戏逻辑均未受影响。Pathwright 仅改变路径计算的速度,而不改变生物决定做什么。
村民繁殖器还能正常工作吗?
可以。村民需要到达他们的床和工作台才能繁殖。Pathwright 确保没有活跃路径的实体始终立即进行寻路,因此它们永远不会卡在等待状态。
朝我走来的实体感觉会有不同吗?
不会。针对玩家或实体的实体始终使用同步、未缓存、全速的寻路。LOD(细节层次)和异步仅适用于常规移动——不适用于战斗。
这会损坏我的世界吗?
不会。Pathwright 从不写入方块数据或修改世界状态。它仅改变路径的计算方式和计算时机。
如果与其他模组冲突怎么办?
大多数情况下不会发生冲突,但如果确实发生了:在 pathwright.json 中禁用导致冲突的模块。这三个系统相互独立——你可以仅运行缓存、仅运行 LOD、仅运行异步,或者任意组合。
Pathwright
Mob pathfinding optimization for Minecraft 26.1.2.
Pathwright targets one of the most expensive hot-paths in Minecraft's server loop: mob pathfinding. Every mob that wants to move somewhere has to compute a path — and in vanilla, every single one of those calculations happens on the main server thread, one after another. Pathwright replaces that with a three-layer optimization system. Every layer is independently toggleable, so you can disable anything that conflicts with another mod in a single config line.
Summary
The Pathwright mod makes mob pathfinding faster by computing paths smarter. Instead of recalculating every mob's path every tick on the main thread, Pathwright caches paths that have already been computed, offloads path updates to background threads, and slows down path recalculation for mobs that are far away from any player. This keeps your TPS higher and your server loop shorter. The mod is especially helpful on servers with lots of mobs — mob farms, breeders, large group AI — but also makes a noticeable difference in singleplayer and locally hosted worlds where the server and client share the same CPU.
Performance Improvements
TPS (Server Ticks Per Second)
Pathwright's optimizations live entirely on the server side. TPS gains depend on how many mobs are loaded and actively pathfinding:
Estimated TPS improvement:
- +1 – 3 TPS in a typical survival world with normal mob counts
- +3 – 8 TPS on mob farms, breeders, or servers with 100+ active pathfinding mobs
- Larger gains the more mobs are far from players (LOD system kicks in)
FPS (Client Frames Per Second)
NB!
FPS improvements will only be seen when the server/world is running on the same computer as the client — for example when hosting a server for you and your friends locally on your PC, or playing singleplayer. When the mod is put on an externally hosted server you will experience that the server runs smoother rather than your client getting higher FPS.
When the server and client share the same CPU:
1. Fewer server lag spikes → smoother animation interpolation
When the server misses a tick (falls below 20 TPS), the client interpolates entity positions incorrectly. Rubber-banding and stuttering trace back to server lag. Pathwright keeps the server at 20 TPS more consistently, which the client experiences as visibly smoother movement even if your GPU FPS hasn't changed.
2. Singleplayer / integrated server
Every millisecond saved in the server tick is a millisecond returned to the render thread. In a typical survival world with mobs:
- Async pathfinding moves path calculations off the main thread entirely
- LOD throttling eliminates redundant calculations for mobs you can't even see
Estimated singleplayer FPS improvement: +2 – 8 FPS at 60 FPS baseline; higher gains on mob-heavy worlds, mob farms, or villager breeders.
How Each Optimization Works
Async Pathfinding
In vanilla, when a mob needs a new path — a zombie chasing you, a villager walking home — the entire path calculation runs on the main server thread. This blocks everything else until it's done. In a world with dozens of mobs all trying to recalculate their paths at once, this stacks up fast.
Pathwright offloads path updates to a small background thread pool. When a mob already has an active path and needs to recalculate (for example, you moved and it needs to reroute), the calculation happens off the main thread and the result is applied on the next tick. New paths — when a mob has no path at all and needs to start moving — are still computed synchronously, so mobs start moving immediately without any delay.
Mobs in combat always get synchronous pathfinding. Async is only used for routine movement updates.
Path Result Caching
Many mobs in the same area often travel the same routes — villagers walking between the same workstation and bed, for example. Pathwright caches the results of completed path calculations. If another mob needs to go from the same position to the same destination in the same world state, it reuses the already-computed path instead of recalculating from scratch.
The cache invalidates automatically when blocks change (a door opens, a wall is placed) so cached paths never become stale. Paths to moving targets like players or other mobs are never cached — those change every tick anyway.
Pathfinding LOD (Level of Detail)
Close to players, mobs need accurate, frequently updated pathfinding. Far away from players, it genuinely doesn't matter if a mob updates its path every tick or every 15 ticks — you can't see the difference. Pathwright applies this insight: mobs more than 48 blocks from any player only recalculate their paths every 15 ticks instead of every tick.
Mobs in combat, mobs that were recently hurt, and mobs with no active path are never throttled regardless of distance. LOD only affects routine movement updates on mobs that are already traveling somewhere.
Configuration
config/pathwright.json — auto-created with safe defaults on first launch:
{
"enablePathCaching": true,
"pathCacheSize": 1024,
"pathCacheExpiryTicks": 200,
"enableLOD": true,
"lodDistance": 48.0,
"lodTickInterval": 15,
"enableAsync": true,
"asyncThreadCount": 2
}
All three modules are independently toggleable. asyncThreadCount defaults to 2 — increasing this helps on servers with many mobs, but don't set it higher than your CPU core count minus 1.
FAQ — just that i am answering my own questions heh
Will this change how my mob farms work?
No. Mob behavior, attack AI, breeding, and all gameplay logic is untouched. Pathwright only changes how quickly paths get calculated, not what the mobs decide to do.
Will villager breeders still work?
Yes. Villagers need to reach their beds and workstations to breed. Pathwright ensures mobs with no active path always get immediate pathfinding, so they never get stuck waiting.
Will mobs walking toward me feel different?
No. Mobs targeting a player or entity always get synchronous, uncached, full-speed pathfinding. LOD and async only apply to routine movement — not combat.
Can this corrupt my world?
No. Pathwright never writes block data or modifies world state. It only changes how paths are computed and when.
What if it conflicts with another mod?
Most sertantly wont make conflicts but in the case it does: Disable whichever module causes the conflict in pathwright.json. All three systems are independent — you can run caching only, LOD only, async only, or any combination.
评论 0
登录后参与评分
还没有评论,来抢沙发吧