Skip to content

StructuredTagEditor

Since 2.2.9

StructuredTagEditor edits an NBT Tag as a tree. It supports primitive tags, lists, compounds and NBT arrays, so users do not need to type raw SNBT for every change.

StructuredTagEditor with an expanded CompoundTag
An expanded CompoundTag. Each row exposes the key, NBT type, and an editor or summary for its value.
java
var editor = new StructuredTagEditor()
        .setCompoundTagOnly()
        .setValue(tag, false)
        .setTagResponder(updated -> save(updated));

The editor copies assigned tags. Treat the callback value as the edited result and copy it before retaining it.

APIDescription
setValue(Tag, boolean)Replaces the edited value.
setTagResponder(Consumer<Tag>)Receives each accepted change.
setTagValidator(Predicate<Tag>)Rejects values that do not meet an application rule.
setCompoundTagOnly()Limits the root to CompoundTag.
setListOnly()Limits the root to ListTag.
setAny()Allows every tag kind.

TagField integration

TagField now opens this editor from its edit button. Existing setCompoundTagOnly(), setListOnly() and validators are forwarded to the dialog, so no extra setup is needed for the standard field.

Released under the MIT License.