Add NBTPath#of(Tag, Tag)#2
Open
Taskeren wants to merge 6 commits into
Open
Conversation
Glavo
reviewed
Jun 9, 2026
Glavo
reviewed
Jun 16, 2026
Glavo
left a comment
Member
There was a problem hiding this comment.
本审查建议由 GPT-5 生成
已将具体审查建议标注在对应代码行。
| @SuppressWarnings({"DataFlowIssue", "unchecked"}) | ||
| @Contract(pure = true) | ||
| static @Nullable <T extends Tag> NBTPath<T> of(T tag, @Nullable Tag expectedRoot) throws IllegalArgumentException, IllegalStateException { | ||
| ParentTag<?> parentTag = tag.getParentTag(); |
Member
There was a problem hiding this comment.
本审查建议由 GPT-5 生成
[P2] 这里改用 tag.getParentTag() 会把 parent 是 Chunk 的 rootTag 当成“没有 parent”。但 Tag#getParent() 允许 parent 是 Chunk,NBTPathImpl.select 也支持从 Chunk 查询。结果是 NBTPath.of(chunk.getRootTag(), null) 返回 null,而 chunk 内部子 tag 也无法自然生成相对 Chunk 可用的 path,调用方必须额外知道并传入 chunk.getRootTag(),和 NBTParent 支持的根类型不一致。
| parentTag = parent; | ||
| } | ||
|
|
||
| if (parentTag != expectedRoot) |
Member
There was a problem hiding this comment.
本审查建议由 GPT-5 生成
[P2] expectedRoot == null 会让非根 tag 固定抛 IllegalStateException。例如 root.addTag("x", tag) 后调用 NBTPath.of(tag, null),循环会停在实际 top root,随后这里的 parentTag != expectedRoot 恒为 true。这个 nullable 参数看起来应支持“使用实际 top of tree”,但当前实现只在显式传入 root tag 时可用,测试也没有覆盖 null root。
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.
Added a util function to create NBTPath from existing tag trees.
by the way, the output ofFixed.NBTPathImpl#toStringis pretty weird.