Repository navigation
Predicates
Predicates are preconditions that determine whether the action of a recipe will be applied, based on arithmetic/logical conditions on fields.
There are two ways to address fields. The following two snippets are equivalent.
when:
villager.profession: none # Accesses "villager.profession"
villager.world.time: "> 1000" # Accesses "villager.world.time" when:
villager:
profession: none # Accesses "villager.profession"
world.time: "> 1000" # Accesses "villager.world.time" (you can mix and match)There are three Boolean logic predicates: and, or, not.
and and or takes a list of other predicate blocks.
when: # Example 1
and: # both predicate blocks 1 and 2 must be fulfilled
# predicate block 1
- villager.profession: LIBRARIAN
# predicate block 2
- result.type: "minecraft:enchanted_book"
# you can add more predicate blocks to the list
when: # Example 2
or: # only one of the predicate blocks needs to be fulfilled
# predicate block 1
- villager.profession: ARMORER
# predicate block 2
- villager.profession: WEAPONSMITH
# you can add more predicate blocks to the listOf course, the when: block implicitly ands predicates inside the block for you.
(i.e. all predicates in a when: block must be fulfilled)
Therefore, example 1 is equivalent to the following:
when: # both predicates must be fulfilled
villager.profession: LIBRARIAN
result.type: "minecraft:enchanted_book"
# you can add more predicates to the blocknot takes a single predicate block.
when: # predicate must not be fulfilled
not:
villager.profession: LIBRARIANSee fields and how to use them.
profession - the profession of a villager
All professions as of 1.16:
NONE,
ARMORER,
BUTCHER,
CARTOGRAPHER,
CLERIC,
FARMER,
FISHERMAN,
FLETCHER,
LEATHERWORKER,
LIBRARIAN,
MASON,
NITWIT,
SHEPHERD,
TOOLSMITH,
WEAPONSMITH
type - villager biome
All types as of 1.16:
DESERT,
JUNGLE,
PLAINS,
SAVANNA
SNOW,
SWAMP,
TAIGA
To match a librarian villager:
when:
villager.profession: LIBRARIANTo match both toolsmith and weaponsmith villagers:
when:
or:
- villager.profession: TOOLSMITH
- villager.profession: WEAPONSMITHOr, with a regular expression: (Don't use regular expressions if you don't know how to write them!)
when:
villager.profession: matches ^(TOOL|WEAPON)SMITH$You can match items in the 2 ingredient slots and the result slot.
Fields: ingredient-0, ingredient-1, result