Skip to content JsonPatcher Docs beta

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.

(no namespace)

Library text : jsonpatcher:text

Contains utilities for working with minecraft text objects.

More information can be found on the minecraft wiki page.

Requires libgroup(+minecraft-data)

Function text.keybind: (key: string) -> TextBuilder

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

Function text.literal: (text: string) -> TextBuilder

Creates a text builder with literal contents.

Property text.nbt: function

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

Function text.parse: (text: string | array | object) -> TextBuilder

Parses json text into a text builder for convenient editing.

Function text.score: (name: string, objective: string) -> TextBuilder

Creates a text builder with scoreboard value contents.

Function text.selector: (selector: string, separator: {TextBuilder | null}?) -> TextBuilder

Creates a text that displays selected entity names.

Function text.translatable: (key: string, args: TextBuilder*) -> TextBuilder

Creates a text builder with translatable content.

Function text.translatableWithFallback: (key: string, fallback: string, args: TextBuilder*) -> TextBuilder

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

Type TextBuilder based on 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.append: (children: TextBuilder*) -> TextBuilder

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

Function TextBuilder.bold: (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.clickEvent: (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.color: (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.font: (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.

Function TextBuilder.hoverEvent: (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.insertion: (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.italic: (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: (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.strikethrough: (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.toJson: () -> object

Converts the builder to json for passing to minecraft

Function TextBuilder.underlined: (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.

Namespace recipepatcher

The RecipePatcher system allows easy bulk-modification of recipes in an extensible way. The jsonpatcher:recipepatcher library allows registering transformations to recipes, while the jsonpatcher:recipepatcher/templates library allows integrating new recipe types.

RecipePatcher works by matching each recipe against a template, selected based on the type field. The template picks out notable fields in the recipe, which then get transformed. Patching is performed from a regular patch with priority -100, which means that most patches will run after RecipePatcher.

Requires libgroup(%jsonpatcher:recipepatcher)

Library recipepatcher : jsonpatcher:recipepatcher

Core API for registering recipe transforms and replacements. This library should be used from within a metapatch.

Requires libgroup(%jsonpatcher:recipepatcher)

Function recipepatcher.recipepatcher._internal_use: (callback: (state: object) -> null) -> null

Internal hook used by recipe patch applicators to read state.

Function recipepatcher.recipepatcher.replaceIngredient: (from: string, to: string) -> null

Register a simple ingredient replacement by string id. Both item ids and #-prefixed tag ids are supported.

Function recipepatcher.recipepatcher.replaceOutput: (from: string, to: string) -> null

Register a simple output replacement by item id.

Function recipepatcher.recipepatcher.transformField: (field: string, transform: (value: unknown) -> unknown | null) -> null

Register a transform for a named recipe field collected by templates. Named fields represent things like cooking time. The first argument is the name of the field as registered by templates.

Function recipepatcher.recipepatcher.transformIngredients: (transform: (ingredient: recipepatcher.Ingredient) -> recipepatcher.Ingredient | null) -> null

Register a transform that can rewrite ingredients. Multiple transforms get applied in sequence. If a transformer returns null the previous ingredient is kept.

Function recipepatcher.recipepatcher.transformOutput: (transform: (output: recipepatcher.ItemStack) -> recipepatcher.ItemStack | null) -> null

Register a transform that can rewrite output stacks. Multiple transforms get applied in sequence. If a transformer returns null the previous output is kept.

Function recipepatcher.recipepatcher.transformRecipes: (type: string, transform: (recipe: object) -> object | null) -> null

Register a transform that can mutate whole recipes of a given type. Multiple transforms get applied in sequence. If a transformer returns null the previous recipe is kept. The first argument is the recipe type id to match against, such as minecraft:crafting_shaped.

Type ItemStackObject based on object

Object form of an item stack with id, count, and components.

Property recipepatcher.ItemStackObject.components: object

Optional components payload for the stack.

This property is optional and may not be present

Property recipepatcher.ItemStackObject.count: number

Number of items in the stack.

This property is optional and may not be present

Property recipepatcher.ItemStackObject.id: string

Item identifier, usually a namespaced id like minecraft:stick.

Type alias Ingredient = string | string[] | object

A recipe ingredient value as used by vanilla JSON recipes.

Type alias ItemStack = string | recipepatcher.ItemStackObject

An item stack reference in recipe output fields.