Add /guide command to lead players to an NPC by name - #296
Open
UniqueBitter wants to merge 1 commit into
Open
Conversation
Adds a player-facing /guide (alias /yl) command that draws a glowing path from the player to a target NPC located by name/UUID match, with a client-side curve renderer (Chaikin-subdivided, distance-faded, with a diamond end marker) and frame-budgeted server-side A* pathfinding for long-range targets, refreshed incrementally as the player moves. - New request/data packets (GuideQueryPacket, GuideTargetPacket), exempted from the OpsOnly gate via a new AbstractPacket.bypassOpsOnly() hook since this is meant for regular players, not just ops (kamkeel/npcs/network/AbstractPacket.java, PacketHandler.java) - Server-side NPC lookup/name matching and a queue that defers actual pathfinding queries to the main server tick (noppes/npcs/guide/*, ServerTickHandler.java) - Client-side session state machine and renderer (noppes/npcs/client/guide/*), registered from ClientProxy - Unit tests for the curve geometry, fade curve, render config, and name matcher (src/test/java/.../guide/*) Known limitations: cannot locate the target NPC while its chunk is unloaded; no cross-dimension support.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary(概述)
新增一个面向普通玩家的
/guide <NPC名>指令(别名/yl),按名字/UUID 定位目标 NPC,并在世界里画出一条通往它的发光路径引导玩家过去。不需要 OP 权限。客户端负责路径曲线渲染(距离衰减淡出 + 终点菱形标记),服务端负责按帧预算做寻路,避免长距离寻路卡顿主线程。主要改动
GuideCommand(/guide,别名/yl)—— 支持按名字模糊匹配定位 NPC、/guide stop取消引路、不带参数时查看当前引路目标与距离GuideNpcLocator/GuideNameMatcher:按名字/UUID 查找 NPC,名字匹配逐级放宽(全字匹配→前缀→包含)GuideServerTasks:引路查询在网络 IO 线程收到后先入队,实际查询挪到服务端主线程 tick 里执行,避免线程不安全问题GuideQueryPacket(请求) /GuideTargetPacket(下发目标位置),两者都通过新增的AbstractPacket.bypassOpsOnly()钩子豁免了服务器"仅 OP 可用"总闸——这个闸原本是给编辑类指令用的,不应该挡住这种面向所有玩家的功能GuideSession:客户端引路会话状态机GuideCurve/GuidePathfinder:Chaikin 曲线细分 + 分帧 A* 寻路(按预算跑,算不完就先给一段能走的路径,剩下的下一帧继续算)GuideRenderer/GuideFade/GuideRenderConfig:死亡空间风格的贴地发光带,能量脉冲沿线流向目标,近处清晰、远处(20 格外)淡出,终点 15 格内菱形标记开始渐显、5 格内完全不透明GuideCurveTest、GuideFadeTest、GuideRenderConfigTest、GuideNameMatcherTest,共 34 个单测覆盖曲线几何、淡出曲线、渲染参数、名字匹配逻辑测试情况
(构建前需要
git submodule update --init --recursive拉取gradle-plugins/src/api两个子模块,并使用真正的 JDK 8 — 只有 JRE8 会因缺tools.jar编译不过gradle-plugins:compileGroovy)效果截图/GIF 暂缺,后续会在这个 PR 里补充;如果想现在看效果,拉这个分支本地跑一下
/guide <NPC名>就能看到。已知限制
备注
本分支基于当前
devHEAD(1.11.2-beta1)。发现dev分支自身在CustomNpcs.java里有两处与本 PR 无关的预置编译错误(PlayerData.flushEffects()/save(boolean)方法签名不存在),这两行代码本 PR 未做任何改动,如果 CI 因此报错请知悉与本改动无关。