Other Models
Working with Regular Expressions
Now you have 2 tools for working with regular expressions:
rpt:matchproperty for theminecraft:conditionmodel
calls on_true when the custom_name component matches the regular expression specified in regex:
json
{
"model": {
"type": "condition",
"property": "rpt:match",
"regex": "^Hello", // All strings starting with "Hello"
"on_true": {
...
},
"on_false": {
...
}
}
}rpt:regexmodel
Checks if there are matches with the regular expression in the when list with the custom_name component. The syntax here is very similar to minecraft:select:
json
{
"model": {
"type": "rpt:regex",
"cases": [
{
"when": ["^Hello", "^Привет"],
"model": {
"type": "model",
"model": "item/diamond"
}
},
{
"when": ["123"],
"model": {
"type": "model",
"model": "item/raw_iron"
}
}
]
}
}