JsonPatcher Docsbeta

Datapack Library Symbols

This page contains documentation for symbols in the standard library of the JsonPatcher mod, available only to patches loaded along with datapack files. Unless something is otherwise stated, everything here should be available to all code ran by the mod.

Type TextBuilder of object

A modifiable text object with methods to change settings. Can be converted to json using the toJson function.

More information can be found on the minecraft wiki page.

Function TextBuilder.hoverEvent

Type: (action: string, contents: any) -> TextBuilder

Sets the hover event of this builder and returns self. See the minecraft wiki page for more details.

Function TextBuilder.clickEvent

Type: (action: string, value: string) -> TextBuilder

Sets the click event of this builder and returns self. See the minecraft wiki page for more details.

Function TextBuilder.toJson

Type: () -> object

Converts the builder to json for passing to minecraft

Function TextBuilder.color

Type: (value: string | null) -> TextBuilder

Sets the color of this builder and returns self. The font should be a color string, a hex color with a prefix of #, or null to clear it.

Function TextBuilder.underlined

Type: (value: {boolean | null}?) -> TextBuilder

Sets the underlined property of this builder and returns self. If a boolean is passed the property is set. If null it passed it is cleared.

Function TextBuilder.insertion

Type: (value: string | null) -> TextBuilder

Sets the insertion of this builder and returns self. The allows for inserting text into the chat field from some contexts. Pass in null to clear.

Function TextBuilder.bold

Type: (value: {boolean | null}?) -> TextBuilder

Sets the bold property of this builder and returns self. If a boolean is passed the property is set. If null it passed it is cleared.

Function TextBuilder.strikethrough

Type: (value: {boolean | null}?) -> TextBuilder

Sets the strikethrough property of this builder and returns self. If a boolean is passed the property is set. If null it passed it is cleared.

Function TextBuilder.italic

Type: (value: {boolean | null}?) -> TextBuilder

Sets the italic property of this builder and returns self. If a boolean is passed the property is set. If null it passed it is cleared.

Function TextBuilder.obfuscated

Type: (value: {boolean | null}?) -> TextBuilder

Sets the obfuscated property of this builder and returns self. If a boolean is passed the property is set. If null it passed it is cleared.

Function TextBuilder.append

Type: (children: TextBuilder*) -> TextBuilder

Adds children to this builder and returns self. The children must also be text builders.

Function TextBuilder.font

Type: (value: string | null) -> TextBuilder

Sets the font of this builder and returns self. The font should be a valid identifier or null to clear it.

Library text

Location: jsonpatcher:text
Requires libgroup(+minecraft-data)

Contains utilities for working with minecraft text objects.

More information can be found on the minecraft wiki page.

Function text.translatable

Type: (key: string, args: TextBuilder*) -> TextBuilder

Creates a text builder with translatable content.

Function text.score

Type: (name: string, objective: string) -> TextBuilder

Creates a text builder with scoreboard value contents.

Property text.nbt

Type: function

Nbt text is currently not supported due to its complexity, please manually build it and use the parse function.

Function text.keybind

Type: (key: string) -> TextBuilder

Creates a text that displays the value of an active keybind.

Function text.selector

Type: (selector: string, separator: {TextBuilder | null}?) -> TextBuilder

Creates a text that displays selected entity names.

Function text.parse

Type: (text: string | array | object) -> TextBuilder

Parses json text into a text builder for convenient editing.

Function text.translatableWithFallback

Type: (key: string, fallback: string, args: TextBuilder*) -> TextBuilder

Creates a text builder with translatable content and fallback text for when the key isn't present.

Function text.literal

Type: (text: string) -> TextBuilder

Creates a text builder with literal contents.