Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support NBT path format #338

Open
rj00a opened this issue May 23, 2023 · 2 comments
Open

Support NBT path format #338

rj00a opened this issue May 23, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request low priority Other issues are more important

Comments

@rj00a
Copy link
Member

rj00a commented May 23, 2023

Describe the problem related to your feature request.

There is currently no support for NBT path format in valence_nbt.

NBT path format support is a prerequisite for a complete command parser and valence_command crate.

What solution would you like?

Add a new path module and feature flag to valence_nbt.

Paths get parsed into a structure that looks something like this:

pub struct NbtPath<S = String> {
    string: S,
    nodes: Vec<NbtPathNode>,
}

pub enum NbtPathNode {
    RootCompoundTag { ... },
    NamedTag { ... },
    NamedCompoundTag { ... },
    ...
}

Once the NbtPath is parsed, lookups can be performed on &Compound or &mut Compound values.

I would also like to see some unit tests and assurance that our implementation closely matches vanilla Minecraft's behavior.

What alternative(s) have you considered?

This is less of an alternative and more of an addition to the above solution, but we could add methods on Compound (named path, path_mut?) similar to serde_json's pointer and pointer_mut methods. The implementation should not parse to an intermediate NbtPath to avoid the associated overhead.

Additional context

#332

@rj00a rj00a added enhancement New feature or request good first issue Good for newcomers labels May 23, 2023
@fdfdjfk3
Copy link

i'd like to try working on this if nobody is doing it already 👍

@dyc3
Copy link
Collaborator

dyc3 commented May 31, 2023

Sounds good, I'll assign you. Looking forward to your PR!

@rj00a rj00a added low priority Other issues are more important and removed good first issue Good for newcomers labels Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request low priority Other issues are more important
Projects
None yet
Development

No branches or pull requests

3 participants