Predicates
This page is about conditions that cannot list values. For conditions that list values, see ingredients.
Predicates are used in many different JSON formats to represent a condition that must be matched by a piece of the JSON format. Unlike ingredients, predicates are not required to list their full contents for display in recipe viewers, though they may be used indirectly to construct displays.
Predicates are defined in Mantle, and support many different vanilla registries. In addition, mods such as Tinkers’ Construct define additional predicate types. The following predicate types are available in Mantle:
- Block: Matches block state values and properties.
- Item: Matches items without item stack data.
- Fluid: Matches fluids without fluid stack data.
- Entity: Matches entities including their current properties.
- Damage: Matches damage source instances, which determine the cause of damage.
Additionally, Tinkers’ Construct adds the following predicate types:
- Material: Matches material variants and their properties.
- Modifier: Modifiers and their properties.
- Tool: Matches tool instances and their current properties.
Format
A predicate may be defined either in compact format or in object format.
In object format, a predicate is defined as follows:
- A predicate object.
- The predicate serializer ID.
- Any other fields specific to the predicate serializer.
If a predicate has no additional fields, or all the additional fields are using the default value, it may be defined compactly using just a string containing the predicate serializer ID as follows:
- The predicate serializer ID.
Common Predicates
All predicates support the predicate serializers defined in the following subsections. Whenever a predicate references another predicate serializer, any predicate serializer for the given type may be used.
Any
The any predicate matches everything. It has a predicate type ID of mantle:any and no additional fields.
Inverted
The inverted predicate matches anything not matched by the nested predicate. It has the following format:
- A predicate object.
- Always
mantle:inverted. - The predicate serializer ID to invert. If that predicate would return true, the inverted predicate returns false.
- Any other fields specific to the inverted predicate serializer.
- Always
And
The “and predicate” matches if all of the nested predicates match. It has the following format:
- A predicate object.
- Always
mantle:and. - List of predicates, all must match for the “and predicate” to match.
- A predicate object. May be any predicate serializer for the desired predicate type.
- Always
Or
The “or predicate” matches if any of the nested predicates match. It has the following format:
- A predicate object.
- Always
mantle:or. - List of predicates, if any match the “or predicate” will match.
- A predicate object. May be any predicate serializer for the desired predicate type.
- Always
Tag
Some predicate types, most notably those defined from vanilla registries, support tag predicates. The tag predicate will match if the input is in the given tag. Unlike other common predicate serializers, not every predicate type supports tag predicates.
Tag predicates have the following format:
- A predicate object.
- Always
mantle:tag. - ID of a tag in the registry associated with the predicate type.
- Always
Variable Predicate
Some predicate types can leverage the Tinkers’ Construct Formula Variable system to check if a value from the world is within the given range. Supporting predicates have the following fields:
- A predicate object.
- Typically
tconstruct:variable_range. - Variable to fetch.
- Minimum value. If unset, defaults to negative infinity (effectively any).
- Maximum value. If unset, defaults to positive infinity (effectively any).
- Specifies the type of interval to match. Options are:
closed(default):minandmaxare both inside the range and will match.open:minandmaxare both outside the range and will not match.left_open:maxwill match butminwill not match.right_open:minwill match butmaxwill not match.
- Typically