Skip to content

Add NBTPath#of(Tag, Tag)#2

Open
Taskeren wants to merge 9 commits into
HMCL-dev:mainfrom
Taskeren:feature-better-path
Open

Add NBTPath#of(Tag, Tag)#2
Taskeren wants to merge 9 commits into
HMCL-dev:mainfrom
Taskeren:feature-better-path

Conversation

@Taskeren

@Taskeren Taskeren commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Added a util function to create NBTPath from existing tag trees.

by the way, the output of NBTPathImpl#toString is pretty weird. Fixed.

Comment thread src/main/java/org/glavo/nbt/NBTPath.java
@Taskeren Taskeren requested a review from Glavo June 9, 2026 14:06

@Glavo Glavo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本审查建议由 GPT-5 生成


已将具体审查建议标注在对应代码行。

Comment thread src/main/java/org/glavo/nbt/NBTPath.java Outdated
Comment thread src/main/java/org/glavo/nbt/NBTPath.java Outdated

@Glavo Glavo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本审查建议由 GPT-5 生成


已将具体审查建议标注在对应代码行。

Comment thread src/main/java/org/glavo/nbt/internal/path/NBTPathImpl.java

@Glavo Glavo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本审查建议由 GPT-5 生成


已将具体审查建议标注在对应代码行。

if (!(tag instanceof Tag currentTag)) return null;
NBTParent<?> parentTag = tag.getParent();
if (parentTag instanceof ParentTag<?>) {
return parentTag instanceof CompoundTag ? new NBTPathNode.NamedSubTag(currentTag.getName()) : new NBTPathNode.Index(currentTag.getIndex());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本审查建议由 GPT-5 生成


[P2] 先支持 ListTag 根再返回索引路径

tag 的 parent 是 ListTag/ArrayTag(或 expectedRoot 本身是这类 ParentTag)时,这里会生成 [index] 作为相对路径;但 NBTPathImpl.select(...) 对初始 parent 只处理 CompoundTagChunkRegionChunk,传入 ListTag/ArrayTag 会直接从 Stream.empty() 开始。因此 NBTPath.of(child, list) 返回的路径无法通过 list.getFirstTag(path) 找回 child,新的 of(Tag, Tag) API 在非 Compound 根上会失效;要么限制/拒绝这类根,要么让选择器从所有 ParentTag 根开始。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants