Matchers¶
TL;DR
A matcher is a small filter object built from if_all, if_any and excluding. Biome and block matchers take all three. The resource-location matcher takes only two. code review
if_any and excluding need 6.2.2
Both keys arrived in 6.2.2, on the block matcher and on the resource location matcher. Before that only if_all exists. See Key availability. code review
Several unrelated keys share this filter shape rather than each inventing one: a world style's biomes, a stuff object's blocks, a scattered entry's biomes, and others. code review
The shape¶
| Key game test | Meaning |
|---|---|
if_all |
Every entry in this list must match |
if_any |
At least one entry in this list must match |
excluding |
None of these may match |
All three were run in a world on a World Style's
citystyles entries. Three city styles differing only in the matcher on the entry
that reaches them: the two gated on a biome that cannot occur built nothing, and
the one excluding it built exactly what an ungated entry builds. game test
Every key is optional, and a matcher with nothing set matches anything. code review
Not every matcher takes all three keys¶
The mod has three matcher types and they do not share a key set. code review
| Matcher | Used by | if_all |
if_any |
excluding |
|---|---|---|---|---|
| Biome matcher | biomes, everywhere it appears |
yes | yes | yes |
| Block matcher | a Stuff Object's blocks and upperblocks |
yes | yes | yes |
| Resource-location matcher | a Stuff Object's buildings |
no | yes | yes |
| code review |
if_all in a buildings matcher fails to load
The resource-location matcher's codec declares if_any and excluding and nothing else, so a buildings matcher using if_all does not parse and the whole Stuff Object fails with it. code review
It would mean nothing there anyway. A chunk holds one building, and one name cannot equal several names at once.
Example: a biome matcher¶
{
"biomes": {
"if_any": ["minecraft:desert", "minecraft:badlands"],
"excluding": ["minecraft:eroded_badlands"]
}
}
That matches desert and badlands, but not eroded badlands. code review
Tags work in place of an exact ID¶
Block matchers and biome matchers both take a #namespace:tag entry instead of an exact ID. code review
{ "blocks": { "if_any": ["#minecraft:planks"] } }
That matches any block in the minecraft:planks tag rather than one plank type. The shipped world style does the same for biomes, with entries such as #minecraft:is_ocean and #minecraft:is_deep_ocean. code review