Descriptions¶
description is the most awkward field in pack.mcmeta. It can be a plain string, a component object, an array of
components, or a translatable component — and in the format-1 era it carried legacy § colour codes.
The library keeps it raw and adds no interpretation of its own.
Plain text¶
This walks the component tree, concatenating text and extra in order. For a nested component:
The tree¶
Styling is preserved on a sealed JsonValue owned by this library — not a Jackson type, so shading Jackson in your
plugin cannot break callers.
JsonValue.JsonObject description =
assertInstanceOf(JsonValue.JsonObject.class, metadata.pack().description());
assertEquals(new JsonValue.JsonString("gold"), description.get("color"));
The variants are JsonString, JsonNumber, JsonBoolean, JsonNull, JsonArray and JsonObject, so a switch
over them is exhaustive. toJsonString() serialises any of them back to JSON.
Legacy § codes¶
Two different things get called "formatting", and the library treats them differently:
- Legacy
§ccodes live inside string values. They are preserved verbatim —plainText()will hand them back to you untouched, and aLEGACY_FORMATTING_CODESdiagnostic tells you they are present. - Structured styling —
"color": "gold","bold": true— has no§at all. Those stay as fields on the tree.
The library will not synthesise §c from "color": "red", nor strip § codes to make output tidy. Both would be
inventing or discarding information. Rendering is your decision, and the raw data is there to make it.
Translatable components¶
plainText() prefers text, then fallback, then the translate key itself:
{ "translate": "pack.name", "fallback": "My Pack" } -> "My Pack"
{ "translate": "pack.name" } -> "pack.name"
No translation is attempted — the library has no locale data and will not guess.