Regex Identifier
Identifiers (officially resource locations) are used all over Minecraft for identifying stuff like items, blocks, entities, loot tables and so on.
They consist of a namespace and a path, separated by a colon. Full documentation on identifiers can be found here.
Loot modifier predicates often use regex identifiers for matching these identifiers.
A regex identifier allows matching either a literal identifier or a regex pattern.
Instead of matching an exact piece of text, regex allows describing a pattern to match many possible variations.
For that, regex uses metacharacters. The most useful combination of which for matching identifiers is .*
, which matches any character from zero to infinite times.
This is very useful for loot modifier predicates because you can build patterns like minecraft:.*_ingot
for matching any ingot from minecraft.
Full documentation on supported regex syntax can be found here, and you can use a site like regex101 to write and test you regular expressions (just make sure to choose the Java 8
flavor)
A RegexIdentifier
in json can either be an inlined string or an object with the regexPattern
field.
Examples:
{
"value1": "minecraft:diamond_sword",
"value2": { "regexPattern": "minecraft:.*_sword" },
"value3": { "regexPattern": "minecraft:.*" },
"value4": { "regexPattern": "minecraft:oak_.*" }}