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:

  • (Object): A predicate object.
    • type (Resource Location): 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:

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:

  • (Object): A predicate object.
    • type (Resource Location): Always mantle:inverted.
    • inverted_type (Resource Location): 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.

And

The “and predicate” matches if all of the nested predicates match. It has the following format:

  • (Object): A predicate object.
    • type (Resource Location): Always mantle:and.
    • predicates (Array): List of predicates, all must match for the “and predicate” to match.
      • (predicate): A predicate object. May be any predicate serializer for the desired predicate type.

Or

The “or predicate” matches if any of the nested predicates match. It has the following format:

  • (Object): A predicate object.
    • type (Resource Location): Always mantle:or.
    • predicates (Array): List of predicates, if any match the “or predicate” will match.
      • (predicate): A predicate object. May be any predicate serializer for the desired predicate type.

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:

  • (Object): A predicate object.
    • type (Resource Location): Always mantle:tag.
    • tag (Tag): ID of a tag in the registry associated with the predicate type.

Variable Predicate

Since 1.20

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:

  • (Object): A predicate object.
    • type (Resource Location): Typically tconstruct:variable_range.
    • variable (Formula Variable): Variable to fetch.
    • min (Number): Minimum value. If unset, defaults to negative infinity (effectively any).
    • max (Number): Maximum value. If unset, defaults to positive infinity (effectively any).
    • interval (String): Specifies the type of interval to match. Options are:
      • closed (default): min and max are both inside the range and will match.
      • open: min and max are both outside the range and will not match.
      • left_open: max will match but min will not match.
      • right_open: min will match but max will not match.