Skip to main content

Module typed

Module typed 

Source
Expand description

The typed values’ string forms — one grammar for every format:

WrittenValue
@item:minecraft:stick, @block:minecraft:furnace[facing=north]Value::Ref
@tag:item:minecraft:planksValue::Tag
@Strings.screen.title (set names start upper case)Value::Res
@image:sprite:button, @image:mymod:gui/logoValue::Image
@lang:gui.done (a key as in the lang files)Value::Lang
#RRGGBB, #AARRGGBBValue::Color
@@textthe plain string @text

A string that starts with @ is always one of these (or an error), in any field — so a typo in a reference is never silently plain text.

Functions§

classify
s as a typed value if it’s written as one (@…), the plain string otherwise; @@ escapes a leading @.
escape_at
s with a leading @ doubled, so it reads back as plain text.
format_color
0xAARRGGBB → #RRGGBB when opaque, else #AARRGGBB.
is_res_key
A resource key: identifiers joined by . (screen.title); after the first, a part may start with a digit (item.robes.2_boots).
parse_color
#RRGGBB (opaque) or #AARRGGBB → 0xAARRGGBB.
resource_id
A content id: namespace:path (namespace defaults to minecraft), lower case, with an optional [state] / {nbt} suffix kept as written.
typed_string
The string form of a typed value (None for the untyped ones).