Block predicate

This article is about the system used by features and enchantments. For the similar system used by advancements, see predicate.
This feature is exclusive to Java Edition.
 

A block predicate is a test for the state of a block at a given position in the world. They are used by placement modifiers in placed features, numerous configured features, and enchantments.

JSON Format

Block predicated are defined using the following format:

Types

The following block predicate types exist:

true

Always matches, independent of the block.

  • [NBT Compound / JSON Object]: a block predicate
    • [String] type: true

all_of

Combined multiple block predicates. Matches if all specified block predicates match.

  • [NBT Compound / JSON Object]: a block predicate
    • [String] type: all_of
    • [NBT List / JSON Array] predicates: (Can be empty) The child predicates.
      • [NBT Compound / JSON Object]: A block predicate.

any_of

Combined multiple block predicates. Matches if at least one of the specified block predicates matches.

  • [NBT Compound / JSON Object]: a block predicate
    • [String] type: any_of
    • [NBT List / JSON Array] predicates: (Can be empty) The child predicates.
      • [NBT Compound / JSON Object]: A block predicate.

not

Inverts a given block predicate. Matches if the specified other block predicate does not match.

  • [NBT Compound / JSON Object]: a block predicate
    • [String] type: not
    • [NBT Compound / JSON Object] predicate: The block predicate to invert.

has_sturdy_face

Checks if the block at the specified offset has a full block supporting surface in the specified direction.

  • [NBT Compound / JSON Object]: a block predicate
    • [String] type: has_sturdy_face
    • [NBT List / JSON Array] offset: (optional, defaults to [0,0,0]) A list of 3 integers specifying an [X, Y, Z] block position offset to check.
      • [Int]: Value between -16 and 16 (inclusive).
    • [String] direction: The direction of the block to check if it is sturdy.

inside_world_bounds

Checks if the positions y-level (with specified offset) is within the height limits of the world.

  • [NBT Compound / JSON Object]: a block predicate
    • [String] type: inside_world_bounds
    • [NBT List / JSON Array] offset: (optional, defaults to [0,0,0]) A list of 3 integers specifying an [X, Y, Z] block position offset to check.
      • [Int]: Value between -16 and 16 (inclusive).

matching_block_tag

Checks if the block at the specified offset is in the given block tag.

  • [NBT Compound / JSON Object]: a block predicate
    • [String] type: matching_block_tag
    • [NBT List / JSON Array] offset: (optional, defaults to [0,0,0]) A list of 3 integers specifying an [X, Y, Z] block position offset to check.
    • [String] tag: The block tag without # to check for.

matching_blocks

Checks if the block at the specified offset is one of the specified blocks.

  • [NBT Compound / JSON Object]: a block predicate
    • [String] type: matching_blocks
    • [NBT List / JSON Array] offset: (optional, defaults to [0,0,0]) A list of 3 integers specifying an [X, Y, Z] block position offset to check.
    • [String][NBT List / JSON Array] blocks: Any number of block(s) (an [String] ID, or a [String] tag with #, or an [NBT List / JSON Array] array containing [String] IDs) that will match.

matching_fluids

Checks if the fluid at the specified offset is one of the specified fluid.

  • [NBT Compound / JSON Object]: a block predicate
    • [String] type: matching_fluids
    • [NBT List / JSON Array] offset: (optional, defaults to [0,0,0]) A list of 3 integers specifying an [X, Y, Z] block position offset to check.
    • [String][NBT List / JSON Array] fluids: Any number of fluid(s) (an [String] ID, or a [String] tag with #, or an [NBT List / JSON Array] array containing [String] IDs) that will match.

replaceable

Checks if the block at the specified offset can be replaced by placing blocks.

  • [NBT Compound / JSON Object]: a block predicate
    • [String] type: replaceable
    • [NBT List / JSON Array] offset: (optional, defaults to [0,0,0]) A list of 3 integers specifying an [X, Y, Z] block position offset to check.
      • [Int]: Value between -16 and 16 (inclusive).

solid

Checks if the block at the specified offset is solid.

  • [NBT Compound / JSON Object]: a block predicate
    • [String] type: solid
    • [NBT List / JSON Array] offset: (optional, defaults to [0,0,0]) A list of 3 integers specifying an [X, Y, Z] block position offset to check.
      • [Int]: Value between -16 and 16 (inclusive).

would_survive

Checks if a specified block state is a valid placement at the given offset.

  • [NBT Compound / JSON Object]: a block predicate
    • [String] type: would_survive
    • [NBT List / JSON Array] offset: (optional, defaults to [0,0,0]) A list of 3 integers specifying an [X, Y, Z] block position offset to check.
      • [Int]: Value between -16 and 16 (inclusive).
    • [NBT Compound / JSON Object] state: The blockstate to test.
      • Block state see Template:Nbt inherit/block state/template

Navigation