Block predicate
Minecraft Wiki article. Categories: Java_Edition, Upcoming, Java_Edition_upcoming_tag, Articles_to_be_expanded, Java_Edition_upcoming, Data_packs
This article is reproduced from Block predicate on the Minecraft Wiki. Mirrored from revision 3719015. It is licensed CC BY-NC-SA 3.0 by the Minecraft Wiki contributors — not under the Codex’s CC BY-SA 4.0, and it may not be used commercially. Edits belong upstream, not here.
A block predicate (also known as a placement condition) 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 predicates are defined using the following format:
- [NBT Compound / JSON Object]: a block predicate
- [String] type: The type of the block predicate. See Block predicate § Types for options.
- additional fields depending on [String] type. See Block predicate § Types.
Types
The following block predicate types exist:
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.
- [String] type:
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.
- [String] type:
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.
- [String] type:
height_range
Checks the height of the position against a given range.[upcoming: JE 26.3]
- [NBT Compound / JSON Object]: a block predicate
- [String] type:
height_range - [NBT Compound / JSON Object] min_inclusive: Vertical anchor describing the minimum height required.
- [NBT Compound / JSON Object] max_inclusive: Vertical anchor describing the maximum height required.
- [String] type:
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).
- [String] type:
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.
- [String] type:
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.
- [String] type:
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.
- [String] type:
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.
- [String] type:
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).
- [String] type:
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).
- [String] type:
true
Always matches, independent of the block.
- [NBT Compound / JSON Object]: a block predicate
- [String] type:
true
- [String] type:
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
- [String] type:
History
| Upcoming Java Edition | |||||||
|---|---|---|---|---|---|---|---|
| 26.3 | snap2 | Added minecraft:height_range. | |||||
| snap8 | Added minecraft:volume_match. | ||||||
Navigation
Sources
- Block predicate — Minecraft Wiki, CC BY-NC-SA 3.0, revision 3719015.