Block predicate

From Minecraft Wiki
Jump to navigation Jump to search
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

[edit | edit source]

Block predicated are defined using the following format:

Types

[edit | edit source]

The following block predicate types exist:

Always matches, independent of the block.

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

all_of

[edit | edit source]

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

[edit | edit source]

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.

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

[edit | edit source]

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

[edit | edit source]

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

[edit | edit source]

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

[edit | edit source]

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

[edit | edit source]

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

[edit | edit source]

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

[edit | edit source]

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

[edit | edit source]

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.
[edit | edit source]