Minecraft:Block predicate: Difference between revisions
More actions
Sync: new page from Minecraft |
Sync: updated from Minecraft |
||
| (4 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
{{about|the system used by features and enchantments|the similar system used by advancements|predicate}} | {{about|the system used by worldgen features and enchantments|the similar system used by advancements|predicate}} | ||
{{exclusive|java}} | {{exclusive|java}} | ||
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 [[Minecraft:placed feature]]s, numerous [[Minecraft:configured feature]]s, and [[Minecraft:enchantment definition|enchantments]]. | 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 [[Minecraft:placed feature]]s, numerous [[Minecraft:configured feature]]s, and [[Minecraft:enchantment definition|enchantments]]. | ||
== JSON Format == | == JSON Format == | ||
Block | Block predicates are defined using the following format: | ||
<div class="treeview"> | <div class="treeview"> | ||
* {{nbt|compound}}: a block predicate<section begin="json format" /> | * {{nbt|compound}}: a block predicate<section begin="json format" /> | ||
| Line 14: | Line 14: | ||
== Types == | == Types == | ||
The following block predicate types exist: | The following block predicate types exist: | ||
=== all_of === | === all_of === | ||
| Line 38: | Line 31: | ||
** {{nbt|list|predicates}}: (Can be empty) The child predicates. | ** {{nbt|list|predicates}}: (Can be empty) The child predicates. | ||
*** {{nbt|compound}}: A block predicate. | *** {{nbt|compound}}: A block predicate. | ||
</div> | </div> | ||
| Line 58: | Line 43: | ||
</div> | </div> | ||
=== height_range === | |||
Checks the height of the position against a given range.{{upcoming|JE 26.3}} | |||
<div class="treeview"> | |||
* {{nbt|compound}}: a block predicate | |||
** {{nbt|string|type}}: <code>height_range</code> | |||
** {{nbt|compound|min_inclusive}}: Vertical anchor describing the minimum height required. | |||
** {{nbt|compound|max_inclusive}}: Vertical anchor describing the maximum height required. | |||
</div> | |||
=== inside_world_bounds === | === inside_world_bounds === | ||
Checks if the positions y-level (with specified offset) is within the height limits of the world. | Checks if the positions y-level (with specified offset) is within the height limits of the world. | ||
| Line 92: | Line 87: | ||
** {{nbt|list|offset}}: (optional, defaults to [0,0,0]) A list of 3 integers specifying an [X, Y, Z] block position offset to check. | ** {{nbt|list|offset}}: (optional, defaults to [0,0,0]) A list of 3 integers specifying an [X, Y, Z] block position offset to check. | ||
** {{nbt|string}}{{nbt|list|fluids}}: {{json_ref|fluid|tag=1|tag_link=fluid tag (Java Edition)}} that will match. | ** {{nbt|string}}{{nbt|list|fluids}}: {{json_ref|fluid|tag=1|tag_link=fluid tag (Java Edition)}} that will match. | ||
</div> | |||
=== not === | |||
Inverts a given block predicate. Matches if the specified other block predicate ''does not'' match. | |||
<div class="treeview"> | |||
* {{nbt|compound}}: a block predicate | |||
** {{nbt|string|type}}: <code>not</code> | |||
** {{nbt|compound|predicate}}: The block predicate to invert. | |||
</div> | </div> | ||
| Line 112: | Line 115: | ||
** {{nbt|list|offset}}: (optional, defaults to [0,0,0]) A list of 3 integers specifying an [X, Y, Z] block position offset to check. | ** {{nbt|list|offset}}: (optional, defaults to [0,0,0]) A list of 3 integers specifying an [X, Y, Z] block position offset to check. | ||
*** {{nbt|int}}: Value between -16 and 16 (inclusive). | *** {{nbt|int}}: Value between -16 and 16 (inclusive). | ||
</div> | |||
=== true === | |||
Always matches, independent of the block. | |||
<div class="treeview"> | |||
* {{nbt|compound}}: a block predicate | |||
** {{nbt|string|type}}: <code>true</code> | |||
</div> | </div> | ||
| Line 127: | Line 137: | ||
== History == | == History == | ||
{{info needed section}} | {{info needed section|general history of block predicates. Specifically, when block predicates were added or removed.}} | ||
{{HistoryTable | {{HistoryTable | ||
|{{HistoryLine|upcoming java}} | |{{HistoryLine|upcoming java}} | ||
|{{HistoryLine||26.3|dev=snap2|Added {{cd|minecraft:height_range}}.}} | |{{HistoryLine||26.3|dev=snap2|Added {{cd|minecraft:height_range}}.}} | ||
|{{HistoryLine|||dev=snap8|Added {{cd|minecraft:volume_match}}.}} | |||
}} | }} | ||
| Line 136: | Line 147: | ||
{{Navbox Java Edition technical|datapack}} | {{Navbox Java Edition technical|datapack}} | ||
[[Minecraft:de:Block-Prädikate]] | |||
[[Minecraft:fr:Génération du monde personnalisée/Prédicat de bloc]] | [[Minecraft:fr:Génération du monde personnalisée/Prédicat de bloc]] | ||
[[Minecraft:ja:ワールド生成のカスタマイズ/block predicate]] | [[Minecraft:ja:ワールド生成のカスタマイズ/block predicate]] | ||
[[Minecraft:pt:Geração de mundo personalizado/predicado de bloco]] | [[Minecraft:pt:Geração de mundo personalizado/predicado de bloco]] | ||
[[Minecraft:zh:编码格式/Worldgen#方块谓词]] | [[Minecraft:zh:编码格式/Worldgen#方块谓词]] | ||
Latest revision as of 11:04, 13 August 2026
|
For the {{{Description}}} of the same name, see [[{{{Destination}}}]]. |
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 Minecraft:placed features, numerous Minecraft:configured features, and enchantments.
JSON Format
Block predicates are defined using the following format:
- Template:Nbt: a block predicate<section begin="json format" />
- Template:Nbt: The type of the block predicate. See Template:Slink for options.
- additional fields depending on Template:Nbt. See Template:Slink.<section end="json format" />
Types
The following block predicate types exist:
all_of
Combined multiple block predicates. Matches if all specified block predicates match.
- Template:Nbt: a block predicate
- Template:Nbt:
all_of - Template:Nbt: (Can be empty) The child predicates.
- Template:Nbt: A block predicate.
- Template:Nbt:
any_of
Combined multiple block predicates. Matches if at least one of the specified block predicates matches.
- Template:Nbt: a block predicate
- Template:Nbt:
any_of - Template:Nbt: (Can be empty) The child predicates.
- Template:Nbt: A block predicate.
- Template:Nbt:
has_sturdy_face
Checks if the block at the specified offset has a full block supporting surface in the specified direction.
- Template:Nbt: a block predicate
- Template:Nbt:
has_sturdy_face - Template:Nbt: (optional, defaults to [0,0,0]) A list of 3 integers specifying an [X, Y, Z] block position offset to check.
- Template:Nbt: Value between -16 and 16 (inclusive).
- Template:Nbt: The direction of the block to check if it is sturdy.
- Template:Nbt:
height_range
Checks the height of the position against a given range.Template:Upcoming
- Template:Nbt: a block predicate
- Template:Nbt:
height_range - Template:Nbt: Vertical anchor describing the minimum height required.
- Template:Nbt: Vertical anchor describing the maximum height required.
- Template:Nbt:
inside_world_bounds
Checks if the positions y-level (with specified offset) is within the height limits of the world.
- Template:Nbt: a block predicate
- Template:Nbt:
inside_world_bounds - Template:Nbt: (optional, defaults to [0,0,0]) A list of 3 integers specifying an [X, Y, Z] block position offset to check.
- Template:Nbt: Value between -16 and 16 (inclusive).
- Template:Nbt:
matching_block_tag
Checks if the block at the specified offset is in the given block tag.
- Template:Nbt: a block predicate
- Template:Nbt:
matching_block_tag - Template:Nbt: (optional, defaults to [0,0,0]) A list of 3 integers specifying an [X, Y, Z] block position offset to check.
- Template:Nbt: The block tag without
#to check for.
- Template:Nbt:
matching_blocks
Checks if the block at the specified offset is one of the specified blocks.
- Template:Nbt: a block predicate
- Template:Nbt:
matching_blocks - Template:Nbt: (optional, defaults to [0,0,0]) A list of 3 integers specifying an [X, Y, Z] block position offset to check.
- Template:NbtTemplate:Nbt: Template:Json ref that will match.
- Template:Nbt:
matching_fluids
Checks if the fluid at the specified offset is one of the specified fluid.
- Template:Nbt: a block predicate
- Template:Nbt:
matching_fluids - Template:Nbt: (optional, defaults to [0,0,0]) A list of 3 integers specifying an [X, Y, Z] block position offset to check.
- Template:NbtTemplate:Nbt: Template:Json ref that will match.
- Template:Nbt:
not
Inverts a given block predicate. Matches if the specified other block predicate does not match.
- Template:Nbt: a block predicate
- Template:Nbt:
not - Template:Nbt: The block predicate to invert.
- Template:Nbt:
replaceable
Checks if the block at the specified offset can be replaced by placing blocks.
- Template:Nbt: a block predicate
- Template:Nbt:
replaceable - Template:Nbt: (optional, defaults to [0,0,0]) A list of 3 integers specifying an [X, Y, Z] block position offset to check.
- Template:Nbt: Value between -16 and 16 (inclusive).
- Template:Nbt:
solid
Checks if the block at the specified offset is solid.
- Template:Nbt: a block predicate
- Template:Nbt:
solid - Template:Nbt: (optional, defaults to [0,0,0]) A list of 3 integers specifying an [X, Y, Z] block position offset to check.
- Template:Nbt: Value between -16 and 16 (inclusive).
- Template:Nbt:
true
Always matches, independent of the block.
- Template:Nbt: a block predicate
- Template:Nbt:
true
- Template:Nbt:
would_survive
Checks if a specified Minecraft:block state is a valid placement at the given offset.
- Template:Nbt: a block predicate
- Template:Nbt:
would_survive - Template:Nbt: (optional, defaults to [0,0,0]) A list of 3 integers specifying an [X, Y, Z] block position offset to check.
- Template:Nbt: Value between -16 and 16 (inclusive).
- Template:Nbt: The blockstate to test.
- Template:Nbt:
History
Template:Navbox Java Edition technical
Minecraft:de:Block-Prädikate Minecraft:fr:Génération du monde personnalisée/Prédicat de bloc Minecraft:ja:ワールド生成のカスタマイズ/block predicate Minecraft:pt:Geração de mundo personalizado/predicado de bloco Minecraft:zh:编码格式/Worldgen#方块谓词