item predicates - mickelus/tetra GitHub Wiki

Item predicates

Item predicates are used in both vanilla minecraft and in tetra to test if an item matches some criteria, e.g. in advancements to check if the player has acquired an item or in a tetra schematic to test if an item has some required module. Forge allows mods to add new types of item predicates, a type field in a predicate's json determines the which type of predicate that's to be used. Tetra adds a few item predicate related to modular items that can be used in datapacks or by other mods.

Modular item predicates

Modular item predicates can be used to test if an item has some module, a specific module variant or if it has some improvement. Type identifier: tetra:modular_item

Example:

This predicate would match items for which all of these are true:

  • have either the "double/basic_pickaxe_right" or the ""double/basic_pickaxe_left"
  • has a module with the variant "basic_pickaxe/iron" in the target slot
  • has a module with the variant "basic_handle/oak" in the "double/handle" slot
  • does not have the "head_hone/pickaxe_efficiency" improvement (regardless of level)
  • has level 1 of the "head_hone/pickaxe_tier" improvement
{
    "type": "tetra:modular_item",
    "modules": [
        ["double/basic_pickaxe_right"],
        ["double/basic_pickaxe_left"]
    ],
    "variants": {
        "basic_pickaxe/iron": "#slot",
        "basic_handle/oak": "double/handle"
    },
    "improvements": {
        "!head_hone/pickaxe_efficiency": -1,
        "head_hone/pickaxe_tier": 1
    }
}

Format:

modules

A matrix of module keys, the item has to have modules matching at least one row for this to pass. In contexts targeting a specific module slot (e.g. schematic requirements) and if the rows contain a single module key, this will only match against the target module slot.

variants

An object of key value pairs where the keys are module variant identifiers and the values are slots. The value "#slot" can be used to check if the target slot (if one exist in the context) has the module variant, using this in a context without a target slot (e.g. advancements) would cause the predicate to always fail.

Note: This may change due to it being so different from how modules and improvements are checked.

improvements

An object of key value pairs where the keys are improvement identifiers and the values are integer values representing improvement levels. Prefixing the key with "!" would require the item to not have the improvement. A value of -1 would cause it to match regardless which level the improvement is.

Material item predicates

Material item predicates can be used to test if an itemstack matches a material that belongs to some material category. Type identifier: tetra:material

Example:

{
    "type": "tetra:material",
    "category": "fabric"
}

Format:

category

A material category identifier, matched against the category field on all materials