导航
向玩家显示前往指定坐标的路径。它使用 A* 算法寻找可通行的路径,以红色粉尘粒子绘制路径,并可选择推动玩家沿路径移动。
适用于 Paper 1.21 至 1.21.11,以及 Folia。需要 Java 21。
工作原理
当导航开始时,插件在主线程上复制玩家周围和目标周围的已加载区块,然后在另一个线程上针对该副本运行搜索。未加载的区块被视为墙壁,因此搜索过程不会加载任何内容。当玩家进入新区块、离开路径或上次搜索未找到路径且几秒后,会重新进行搜索。
搜索范围限制在玩家周围 96 个方块内。如果目标距离超过此范围,你会获得到最近可达点的路径,随着你的行走,路径会延伸。搜索使用加权启发式算法,因此路径可能比最短路径稍长,但速度更快。
在 Folia 上,搜索仅能看到属于玩家所在区域的区块,因此路径可能在区域边界处提前停止。
安全模式(默认开启)仅允许最多 3 个方块的掉落。关闭它以允许任何落在实心地面之上的坠落。
命令
| 命令 |
作用 |
/navigate start <x> <y> <z> [safeMode] [follow] [materials] |
开始导航 |
/navigate stop |
停止导航 |
/navigate startfor <player> <x> <y> <z> [safeMode] [follow] [materials] |
为其他玩家开始导航 |
/navigate stopfor <player> |
为其他玩家停止导航 |
safeMode 为 true 或 false。materials 是逗号分隔的方块列表,设置后路径仅在这些方块上行走。
/navigate start 120 64 -300
/navigate start 120 64 -300 false
/navigate start 120 64 -300 true follow
/navigate start 120 64 -300 true STONE,GRASS_BLOCK
跟随
使用 follow 时,玩家通过速度沿路径移动,因此他们会行走、跳上单个方块、攀爬梯子和藤蔓以及游泳。潜行会暂停跟随。如果玩家被推出路径或停止前进,路径会重新搜索。
配置文件中的 follow.speed 是玩家每刻移动的距离,0.22 约为步行速度。
反作弊插件将此视为服务器速度,但某些插件仍可能标记它。如果发生这种情况,请豁免你的玩家。
权限
| 权限 |
作用 |
navigate.use |
使用 /navigate |
navigate.follow |
对自己使用 follow 选项 |
navigate.use.others |
使用 startfor 和 stopfor |
navigate.use.neofetch |
使用 /navigate neofetch |
PlaceholderAPI
安装 PlaceholderAPI 后,有一个 navigate 扩展:direction、yaw、pitch、distance2d、distance3d、x、y、z 和 world,例如 %navigate_distance2d%。
API
Navigate.getInstance().getNavigationService() 启动、停止和列出导航。-api jar 仅包含公共类,因此你可以针对它进行编译。
构建
./gradlew build
jar 文件位于 build/libs。如果设置了 modrinthToken,./gradlew publishPlugin 将上传到 Modrinth,否则执行干运行。
许可证
参见 LICENSE。
Navigate
Shows a player the way to a set of coordinates. It finds a walkable path with A*, draws it as red dust particles, and can optionally push the player along it.
Works on Paper 1.21 up to 1.21.11, and on Folia. Needs Java 21.
How it works
When a navigation starts, the plugin copies the loaded chunks around the player and the target on the main thread, then runs the search on another thread against that copy. Chunks that are not loaded count as walls, so searching never loads anything. The path is searched again when the player enters a new chunk, leaves the path, or when the last search found nothing and a few seconds have passed.
Searches stay within 96 blocks of the player. If the target is farther than that you get a path to the closest reachable point, and it extends as you walk. The search uses a weighted heuristic, so paths can be a little longer than the shortest one in return for being quick.
On Folia the search only sees chunks owned by the player's region, so a path can stop short at a region border.
Safe mode (on by default) only allows drops of up to 3 blocks. Turn it off to allow any fall that ends on solid ground.
Commands
| Command |
What it does |
/navigate start <x> <y> <z> [safeMode] [follow] [materials] |
Start navigating |
/navigate stop |
Stop navigating |
/navigate startfor <player> <x> <y> <z> [safeMode] [follow] [materials] |
Start navigating for another player |
/navigate stopfor <player> |
Stop navigating for another player |
safeMode is true or false. materials is a comma separated list of blocks, and when it is set the path only walks on those blocks.
/navigate start 120 64 -300
/navigate start 120 64 -300 false
/navigate start 120 64 -300 true follow
/navigate start 120 64 -300 true STONE,GRASS_BLOCK
Follow
With follow the player is moved along the path using velocity, so they walk, jump up single blocks, climb ladders and vines, and swim. Sneaking pauses it. If the player gets pushed off the path or stops making progress, the path is searched again.
follow.speed in the config is how far the player moves per tick, 0.22 is about walking speed.
Anti cheat plugins see this as server velocity, but some may still flag it. Exempt your players if that happens.
Permissions
| Permission |
What it does |
navigate.use |
Use /navigate |
navigate.follow |
Use the follow option on yourself |
navigate.use.others |
Use startfor and stopfor |
navigate.use.neofetch |
Use /navigate neofetch |
PlaceholderAPI
With PlaceholderAPI installed there is a navigate expansion: direction, yaw, pitch, distance2d, distance3d, x, y, z and world, for example %navigate_distance2d%.
API
Navigate.getInstance().getNavigationService() starts, stops and lists navigations. The -api jar has only the public classes, so you can compile against it.
Building
./gradlew build
The jars end up in build/libs. ./gradlew publishPlugin uploads to Modrinth if modrinthToken is set, and does a dry run otherwise.
License
See LICENSE.
评论 0
登录后参与评分
还没有评论,来抢沙发吧