Skip to main content

Predicates

List of Predicates

Entity

Entity Predicates are a vanilla feature, and are used in Advancements. See the Minecraft Wiki for full documentation.

TIP

The Minecraft Wiki only shows documentation for the most recent version of Minecraft. If designing an addon for Backpacked on an older version of Minecraft, the wiki may not be 100% accurate. You may find this generator helpful as it will generate the JSON and also allow you to select the Minecraft version to target.

Crafted Item

Crafted Item Predicates are a custom predicate implemented by Backpacked just for crafted items.

KeyTypeRequiredDefaultDescription
namespaceString/ArrayNoThe owner namespace of the item. Example: minecraft or backpacked. Can also be an array of namespaces ["minecraft", "backpacked", "create"].
tagStringNoAn optional item tag. See Minecraft Wiki for more details.
itemsArrayNoAn optional array of item id(s). Example: ["minecraft:stick"]

Examples

Match any item

"predicate": {
// an empty object will match everything
}

Match exactly a stick item

"predicate": {
"items": [
"minecraft:stick"
]
}

Match items that come from the mod with the namespace create and must also have the item tag create:seats

"predicate": {
"namespace": "create",
"tag": "create:seats"
}

Block

note

This predicate is a vanilla feature.

Block Predicate is a vanilla predicate for matching blocks, blockstates, and/or NBT of the block.

KeyTypeRequiredDefaultDescription
blocksArrayNoAn optional. Example: minecraft or backpacked. Can also be an array of namespaces ["minecraft", "backpacked", "create"].
propertiesObjectNoAn optional block position predicate. See Block Position Predicate for more details.
nbtObjectNoAn optional NBT predicate to match against the block entity data

Examples

Block Position

KeyTypeRequiredDefaultDescription
xInteger/ObjectNoAn optional integer or Min Max Predicate to match the x coordinate of a block. Leaving undefined means it accepts any x coordinate.
yInteger/ObjectNoAn optional integer or Min Max Predicate to match the y coordinate of a block. Leaving undefined means it accepts any y coordinate.
zInteger/ObjectNoAn optional integer or Min Max Predicate to match the z coordinate of a block. Leaving undefined means it accepts any z coordinate.

Examples

Match a block position exactly at the coordiantes (0, 0, 0)

{
"x": 0,
"y": 0,
"z": 0
}

Match a block position at the y-level from 0 to 63 (inclusive)

{
"y": {
"min": 0,
"max": 63
}
}

Block Snapshot

Block Snapshot Predicate is a custom predicate implemented by Backpacked that is specific for testing block snapshots. A block snapshot is a capture of a block in the world and its state at the time of capture. The data that is captured is the block state, its position, the biome the block is in, the structure if any, the dimension (e.g. overworld) and the time of day (in the captured dimension).

KeyTypeRequiredDefaultDescription
blockObjectNoThe owner namespace of the item. Example: minecraft or backpacked. Can also be an array of namespaces ["minecraft", "backpacked", "create"].
positionObjectNoAn optional block position predicate. See Block Position Predicate for more details.
biomesArrayNoAn optional array of biome id(s) to test if the block was contained within
structuresArrayNoAn optional array of structure id(s) to test if the captured block was contained within.
dimensionStringNoAn optional id of a dimension type (e.g. minecraft:overworld) to test against the dimension the block snapshot was captured.
time_of_dayInteger/ObjectNoAn optional integer or min/max to test the time of day the block snapshot was captured. Ranges from 0 to 24000. The time may be fixed depending on the dimension type.

Examples

Match fully grown wheat in the dawn of the morning in the overworld

{
"block": {
"blocks": "minecraft:wheat",
"properties": {
"age": 7
}
},
"dimension": "minecraft:overworld",
"time_of_day": {
"min": 0,
"max": 2000
}
}

Match a decorated pot in a trial chamber

{
"block": {
"blocks": "minecraft:decorated_pot"
},
"structures": [
"minecraft:trial_chambers"
]
}

Integer Min/Max

KeyTypeRequiredDefaultDescription
minIntegerNoThe owner namespace of the item. Example: minecraft or backpacked. Can also be an array of namespaces ["minecraft", "backpacked", "create"].
maxIntegerNoAn optional block position predicate. See Block Position Predicate for more details.

Examples

Match a block position exactly at the coordiantes (0, 0, 0)

{
"x": 0,
"y": 0,
"z": 0
}

Match a block position at the y-level from 0 to 63 (inclusive)

{
"y": {
"min": 0,
"max": 63
}
}