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

Modification of (nested) tags #12

Open
PierreSchwang opened this issue Oct 25, 2024 · 0 comments · May be fixed by #13
Open

Modification of (nested) tags #12

PierreSchwang opened this issue Oct 25, 2024 · 0 comments · May be fixed by #13
Labels
enhancement New feature or request

Comments

@PierreSchwang
Copy link

Some syntax-sugar for modifying LinCompoundTags (especially nested in deeper compounds) would be a great addition.

An example would be: After writing a schematic using the WorldEdit SpongeV3 writer I want to add more metdata to the schematic, where the current approach would be something like:

LinCompoundTag root = LinRootEntry.readFrom(LinBinaryIO.read(in)).value();
LinCompoundTag schematic = root.getTag("Schematic", LinTagType.compoundTag());
LinCompoundTag metadata = schematic.getTag("Metadata", LinTagType.compoundTag());

// and write to the final OutputStream
LinBinaryIO.write(new DataOutputStream(resultStream), new LinRootEntry("",
        root.toBuilder()
                .put("Schematic", schematic.toBuilder()
                        .put("Metadata", metadata.toBuilder()
                                .putByte("MyCustomStuff", (byte) 1).build()
                        ).build()
                ).build()
));

A simpler (and more readable) approach would be a helper method like editTag(name, type, lambda) (Discord).

@PierreSchwang PierreSchwang changed the title [FEATURE] Modification of (nested) tags Modification of (nested) tags Oct 25, 2024
@wizjany wizjany added the enhancement New feature or request label Oct 25, 2024
octylFractal added a commit that referenced this issue Oct 26, 2024
@octylFractal octylFractal linked a pull request Oct 26, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging a pull request may close this issue.

2 participants