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

Make NbtTags mutable #15

Open
Gaming32 opened this issue Sep 21, 2022 · 4 comments
Open

Make NbtTags mutable #15

Gaming32 opened this issue Sep 21, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@Gaming32
Copy link

It would be extremely useful to have data structure-based tags (such as NbtCompound) be mutable.

@BenWoodworth
Copy link
Owner

I was actually planning to add mutable versions when I originally started designing the API. I decided against it and probably won't because I'm trying to closely mirror kotlinx.serialization's API. JsonElement, for example

If they ever do add mutable versions (and it might be worth opening an issue/discussion about it) then 100% I'll add those right in!

@BenWoodworth
Copy link
Owner

What's your use case for them? I can think of a few possible alternatives, depending on what you're trying to do.

@Gaming32
Copy link
Author

My use case is using NBT data similar to how Minecraft uses NBT data. Notably, ItemStack mutates the item data NBT. I was able to make my thing work by creating a second set of classes (one for each NbtTag subclass) that are mutable and can be converted to and from NbtTag. However creating a mutable deep copy doesn't feel like the best way.

@Gaming32
Copy link
Author

Gaming32 commented Sep 22, 2022

Also, yes, JsonElement is immutable. I do think that JSON isn't modified directly as much though, as it's usually used purely for serialization. NBT, on the other hand, is often used to store arbitrary dynamic data that has less of a static format.

@BenWoodworth BenWoodworth added the enhancement New feature or request label Apr 25, 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
Projects
None yet
Development

No branches or pull requests

2 participants