Skip to content

Modification of (nested) tags #12

@PierreSchwang

Description

@PierreSchwang

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    To do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions