Minecraft:Block definition: Difference between revisions
More actions
imported>EmeraldBuilder |
Remove broken links to missing pages |
||
| Line 8: | Line 8: | ||
<div class="treeview"> | <div class="treeview"> | ||
* {{nbt|compound}} | * {{nbt|compound}} | ||
** {{nbt|string|format_version}}: The format version of the file. This is a string representing a {{BE}} version. It is recommended to use the latest version. For 26.0 and later, add a leading 1. For example: {{cd|"1.26.0"}} for | ** {{nbt|string|format_version}}: The format version of the file. This is a string representing a {{BE}} version. It is recommended to use the latest version. For 26.0 and later, add a leading 1. For example: {{cd|"1.26.0"}} for 26.0. Preview versions should use the version that it is a preview for (Example: Preview 26.0.27 would be {{cd|"1.26.0"}}). | ||
** {{nbt|boolean|use_beta_features}}: Whether or not this block is using beta features. | ** {{nbt|boolean|use_beta_features}}: Whether or not this block is using beta features. | ||
** {{nbt|compound|minecraft:block}}: The block definition. | ** {{nbt|compound|minecraft:block}}: The block definition. | ||
*** {{nbt|compound|description}}: The technical definition of the block. | *** {{nbt|compound|description}}: The technical definition of the block. | ||
**** {{nbt|string|identifier}}: A namespaced [[Minecraft:identifier]] for the block. This defines the technical name of the block for [[Minecraft:commands]], | **** {{nbt|string|identifier}}: A namespaced [[Minecraft:identifier]] for the block. This defines the technical name of the block for [[Minecraft:commands]], scripts, and other [[Minecraft:add-on]] files. | ||
**** {{nbt|compound|menu_category}}: Defines where the block is located in the [[Minecraft:creative inventory]] and | **** {{nbt|compound|menu_category}}: Defines where the block is located in the [[Minecraft:creative inventory]] and recipe book. | ||
***** {{nbt|string|category}}: The inventory tab to put the block under. Can be {{cd|construction|equipment|items|nature|none|d=or}}. If omitted or {{cd|none}}, the block will not appear in the creative inventory or recipe book. | ***** {{nbt|string|category}}: The inventory tab to put the block under. Can be {{cd|construction|equipment|items|nature|none|d=or}}. If omitted or {{cd|none}}, the block will not appear in the creative inventory or recipe book. | ||
***** {{nbt|string|group}}: The creative inventory group to add the block to. Custom groups can be added via the {{File|file|crafting_item_catalog.json|inline=1}}. Vanilla groups are: <div class="collapsible collapsed collapsetoggle-inline"> | ***** {{nbt|string|group}}: The creative inventory group to add the block to. Custom groups can be added via the {{File|file|crafting_item_catalog.json|inline=1}}. Vanilla groups are: <div class="collapsible collapsed collapsetoggle-inline"> | ||
| Line 29: | Line 29: | ||
=== States === | === States === | ||
The {{nbt|compound|states}} object is used to define custom | The {{nbt|compound|states}} object is used to define custom block states. Only custom states are allowed, using a vanilla state or the "minecraft" namespace will cause an error and fail. | ||
The object consists of state names as properties, and an array of possible values for each state. Integer states can also be defined as a range using an object. Block state values can be queried in permutations using the [[Minecraft:molang]] query <code>"query.block_state(<nowiki>'</nowiki>''<state_name>''<nowiki>'</nowiki>)"</code>. | The object consists of state names as properties, and an array of possible values for each state. Integer states can also be defined as a range using an object. Block state values can be queried in permutations using the [[Minecraft:molang]] query <code>"query.block_state(<nowiki>'</nowiki>''<state_name>''<nowiki>'</nowiki>)"</code>. | ||
| Line 147: | Line 147: | ||
{{HistoryTable | {{HistoryTable | ||
|{{HistoryLine|Bedrock}} | |{{HistoryLine|Bedrock}} | ||
|{{HistoryLine||1.12.0|dev=beta 1.12.0.2|Block definition was added with {{cd|identifier}} defines the identifier of the block. Must have a namespace that isn't {{cd|minecraft}}, {{cd|is_experimental}} only registers the block if the {{cd|Use Experimental Gameplay}} toggle is enabled in world settings and {{cd|register_to_creative_menu}} causes the block to appear in the {{cd|Construction}} category of the creative menu but custom blocks cannot be added to the | |{{HistoryLine||1.12.0|dev=beta 1.12.0.2|Block definition was added with {{cd|identifier}} defines the identifier of the block. Must have a namespace that isn't {{cd|minecraft}}, {{cd|is_experimental}} only registers the block if the {{cd|Use Experimental Gameplay}} toggle is enabled in world settings and {{cd|register_to_creative_menu}} causes the block to appear in the {{cd|Construction}} category of the creative menu but custom blocks cannot be added to the recipe book at this time.}} | ||
|{{HistoryLine||1.16.100|Removed {{cd|is_experimental}} and {{cd|register_to_creative_menu}}.}} | |{{HistoryLine||1.16.100|Removed {{cd|is_experimental}} and {{cd|register_to_creative_menu}}.}} | ||
|{{HistoryLine||1.16.100|dev=beta 1.16.100.56|exp=Holiday Creator Features|Added field {{cd|events}} with {{cd|d=and|add_mob_effect|damage|decrement_stack|die|play_effect|play_sound|remove_mob_effect|run_command|set_block|set_block_at_pos|set_block_property|spawn_loot|swing|teleport|transform|trigger}}.}} | |{{HistoryLine||1.16.100|dev=beta 1.16.100.56|exp=Holiday Creator Features|Added field {{cd|events}} with {{cd|d=and|add_mob_effect|damage|decrement_stack|die|play_effect|play_sound|remove_mob_effect|run_command|set_block|set_block_at_pos|set_block_property|spawn_loot|swing|teleport|transform|trigger}}.}} | ||
| Line 154: | Line 154: | ||
|{{HistoryLine||1.19.40|dev=Preview 1.19.40.21|Added flag {{cd|is_hidden_in_commands}} in {{cd|menu_category}} to control whether or not a block can be used in commands.|{{cd|minecraft:direction}} is no longer exposed as a data-driven block property in properties. Blocks throw a content error when the {{cd|minecraft}} namespace is used.}} | |{{HistoryLine||1.19.40|dev=Preview 1.19.40.21|Added flag {{cd|is_hidden_in_commands}} in {{cd|menu_category}} to control whether or not a block can be used in commands.|{{cd|minecraft:direction}} is no longer exposed as a data-driven block property in properties. Blocks throw a content error when the {{cd|minecraft}} namespace is used.}} | ||
|{{HistoryLine||1.19.70|dev=Preview 1.19.70.23|Released block [[#States|properties]] and [[Minecraft:Block components#Permutations|permutations]] out of experimental in JSON formats 1.19.70 and higher.}} | |{{HistoryLine||1.19.70|dev=Preview 1.19.70.23|Released block [[#States|properties]] and [[Minecraft:Block components#Permutations|permutations]] out of experimental in JSON formats 1.19.70 and higher.}} | ||
|{{HistoryLine||1.20.0|dev=Preview 1.20.0.20|exp=Upcoming Creator Features|Added experimental support for {{cd|BlockTraits}} in block JSON with field {{cd|traits}}. {{cd|BlockTraits}} are a shortcut for creators to add vanilla | |{{HistoryLine||1.20.0|dev=Preview 1.20.0.20|exp=Upcoming Creator Features|Added experimental support for {{cd|BlockTraits}} in block JSON with field {{cd|traits}}. {{cd|BlockTraits}} are a shortcut for creators to add vanilla block states and setter functions to data-driven blocks. Can parse {{cd|minecraft:placement_direction}} with the only available value being {{cd|minecraft:cardinal_direction}}.}} | ||
|{{HistoryLine|||dev=Preview 1.20.0.21|Added the {{cd|minecraft:facing_direction}} to the {{cd|minecraft:placement_direction}}.}} | |{{HistoryLine|||dev=Preview 1.20.0.21|Added the {{cd|minecraft:facing_direction}} to the {{cd|minecraft:placement_direction}}.}} | ||
|{{HistoryLine|||dev=Preview 1.20.0.22|Changed {{cd|minecraft:cardinal_direction}} and {{cd|minecraft:facing_direction}} states from int to string type. {{cd|minecraft:cardinal_direction}} has four values {{cd|["north", "south", "east", "west"]}} and {{cd|minecraft:facing_direction}} has six values {{cd|["down", "up", "north", "south", "east", "west"]}}.}} | |{{HistoryLine|||dev=Preview 1.20.0.22|Changed {{cd|minecraft:cardinal_direction}} and {{cd|minecraft:facing_direction}} states from int to string type. {{cd|minecraft:cardinal_direction}} has four values {{cd|["north", "south", "east", "west"]}} and {{cd|minecraft:facing_direction}} has six values {{cd|["down", "up", "north", "south", "east", "west"]}}.}} | ||
| Line 163: | Line 163: | ||
|{{HistoryLine||1.21.20|dev=Preview 1.21.20.23|Removed the "Holiday Creator Features" experiment Because of this, {{cd|events}} were also removed.}} | |{{HistoryLine||1.21.20|dev=Preview 1.21.20.23|Removed the "Holiday Creator Features" experiment Because of this, {{cd|events}} were also removed.}} | ||
|{{HistoryLine||1.21.60|dev=Preview 1.21.60.23|Updated {{cd|menu_category}} and updated {{cd|group}} parameter to require a namespace e.g. {{cd|minecraft:itemGroup.name.concrete}}.}} | |{{HistoryLine||1.21.60|dev=Preview 1.21.60.23|Updated {{cd|menu_category}} and updated {{cd|group}} parameter to require a namespace e.g. {{cd|minecraft:itemGroup.name.concrete}}.}} | ||
|{{HistoryLine||1.21.130|dev=Preview 1.21.130.20|exp=Upcoming Creator Features|Added a new block trait, {{cd|minecraft:connection}}, to expose behavior like [[Minecraft:fence]]s or | |{{HistoryLine||1.21.130|dev=Preview 1.21.130.20|exp=Upcoming Creator Features|Added a new block trait, {{cd|minecraft:connection}}, to expose behavior like [[Minecraft:fence]]s or glass panes where blocks connect to other blocks around them. Using this trait with the example below adds the bool states {{cd|d=and|minecraft:connection_north|minecraft:connection_east|minecraft:connection_south|minecraft:connection_west}}.}} | ||
|{{HistoryLine||1.21.130|dev=Preview 1.21.130.24|exp=Beta APIs|Added new {{cd|minecraft:corner_and_cardinal_direction}} to the {{cd|minecraft:placement_direction}} block trait, which enables the {{cd|minecraft:corner}} state with values {{cd|none|inner_left|inner_right|outer_left|outer_right|d=and}} to provide similar behavior to how [[Minecraft:stairs]] in Vanilla work. This requires the {{cd|use_beta_features}} flag on your block.}} | |{{HistoryLine||1.21.130|dev=Preview 1.21.130.24|exp=Beta APIs|Added new {{cd|minecraft:corner_and_cardinal_direction}} to the {{cd|minecraft:placement_direction}} block trait, which enables the {{cd|minecraft:corner}} state with values {{cd|none|inner_left|inner_right|outer_left|outer_right|d=and}} to provide similar behavior to how [[Minecraft:stairs]] in Vanilla work. This requires the {{cd|use_beta_features}} flag on your block.}} | ||
|{{HistoryLine||26.0|dev=Preview 26.0.27|The Block Trait {{cd|minecraft:connection}} can now be used without the Upcoming Creator Features toggle.|{{cd|minecraft:corner_and_cardinal_direction}} in {{cd|minecraft:placement_direction}} can now be used without the Beta APIs toggle.}} | |{{HistoryLine||26.0|dev=Preview 26.0.27|The Block Trait {{cd|minecraft:connection}} can now be used without the Upcoming Creator Features toggle.|{{cd|minecraft:corner_and_cardinal_direction}} in {{cd|minecraft:placement_direction}} can now be used without the Beta APIs toggle.}} | ||
| Line 172: | Line 172: | ||
{{Navbox Bedrock Edition}} | {{Navbox Bedrock Edition}} | ||
pt:Definição de bloco | |||
Revision as of 15:39, 9 April 2026
A block definition is a Minecraft:JSON file used to define a custom Minecraft:block and its behavior. Block definition files are located in the Template:File folder of a Minecraft:behavior pack.
Structure
Block definitions are structured as follows:
- Template:Nbt
- Template:Nbt: The format version of the file. This is a string representing a Template:BE version. It is recommended to use the latest version. For 26.0 and later, add a leading 1. For example: Template:Cd for 26.0. Preview versions should use the version that it is a preview for (Example: Preview 26.0.27 would be Template:Cd).
- Template:Nbt: Whether or not this block is using beta features.
- Template:Nbt: The block definition.
- Template:Nbt: The technical definition of the block.
- Template:Nbt: A namespaced Minecraft:identifier for the block. This defines the technical name of the block for Minecraft:commands, scripts, and other Minecraft:add-on files.
- Template:Nbt: Defines where the block is located in the Minecraft:creative inventory and recipe book.
- Template:Nbt: The inventory tab to put the block under. Can be Template:Cd. If omitted or Template:Cd, the block will not appear in the creative inventory or recipe book.
- Template:Nbt: The creative inventory group to add the block to. Custom groups can be added via the Template:File. Vanilla groups are:
- Template:Nbt: Whether or not the block is hidden from commands.
- [[#States|Template:Nbt]]: Definitions of custom block state names and their possible values.
- [[#Traits|Template:Nbt]]: The block traits to enable, which provide access to specific vanilla states.
- Template:Nbt: The block's components. This defines the block's behavior and visuals.
- Template:Nbt: The block's permutations, which allow for components to be added only under certain conditions.
- Template:Nbt: A permutation
- Template:Nbt: The condition when this permutation's components should be active. This should be a Minecraft:molang expression resulting in a boolean.
- Template:Nbt: The components that should be active when the Template:Cd is true.
- Template:Nbt: A permutation
- Template:Nbt: The technical definition of the block.
States
The Template:Nbt object is used to define custom block states. Only custom states are allowed, using a vanilla state or the "minecraft" namespace will cause an error and fail.
The object consists of state names as properties, and an array of possible values for each state. Integer states can also be defined as a range using an object. Block state values can be queried in permutations using the Minecraft:molang query "query.block_state('<state_name>')".
Examples:
<syntaxhighlight lang=json copy> "states": {
"example:string_state": ["a", "b", "c"],
"example:int_state": [1,2,3],
"example:bool_state": [true,false],
"example:int_state_2": {
"min": 0,
"max": 10
}
} </syntaxhighlight>
Traits
The Template:Nbt object is used to add vanilla block traits, which allow for custom blocks to have access to some vanilla block states. This object only gives access to the states, other functionality usually has to be added using permutations. The object consists of traits and their enabled states:
minecraft:connection
Gives blocks the boolean states Template:Cd, allowing for the block to connect to blocks next to it.
- Template:Nbt
- Template:Nbt: Which states to enable. The only valid value is
minecraft:cardinal_connections.
- Template:Nbt: Which states to enable. The only valid value is
Example:
<syntaxhighlight lang=json copy> "traits": {
"minecraft:connection": {
"enabled_states": ["minecraft:cardinal_connections"]
}
} </syntaxhighlight>
minecraft:multi_block
Allows a block to be made up of multiple block parts like a Minecraft:door. This adds the Template:Cd state, which is an integer representing which part this block is in the multi block.
- Template:Nbt
- Template:Nbt: Which states to enable. The only valid value is Template:Cd.
- Template:Nbt: The number of parts that this multi block should have. The value must be between 2 and 4, inclusive.
- Template:Nbt: The direction to place the parts of the multi block in. Can be either Template:Cd.
Example:
<syntaxhighlight lang=json copy> "traits": {
"minecraft:multi_block": {
"enabled_states": [
"minecraft:multi_block_part"
],
"parts": 3,
"direction": "up"
}
} </syntaxhighlight>
minecraft:placement_position
Gives blocks states related to where the player places the block. Two states are available:
minecraft:vertical_half: The half of the block space that the block was placed in, allowing for stair and slab functionality. Possible values are Template:Cd.minecraft:block_face: The block face that the player placed the block on, allowing for log and pillar functionality. Possible values are Template:Cd.
- Template:Nbt
- Template:Nbt: Which states to enable. Valid values are Template:Cd.
Example:
<syntaxhighlight lang=json copy> "traits": {
"minecraft:placement_position": {
"enabled_states": ["minecraft:vertical_half"]
}
} </syntaxhighlight>
minecraft:placement_direction
Gives blocks states related to the direction in which the player places the block. Three states are available:
minecraft:cardinal_direction: The direction the player was facing when the block was placed. Possible values are Template:Cd.minecraft:facing_direction: Same asminecraft:cardinal_direction, but allows up and down as well. Possible values are Template:Cd.minecraft:corner: Allows the block to form corners with other blocks like stairs. Possible values are Template:Cd.
- Template:Nbt
- Template:Nbt: Which states to enable. Valid values are Template:Cd.
minecraft:corner_and_cardinal_directionenables both theminecraft:cardinal_directionandminecraft:cornerstates. - Template:Nbt: The offset to apply to the y rotation of the block. Can be Template:Cd.
- Template:Nbt: A list of blocks (or block tags) to consider for
minecraft:corner.- Template:NbtTemplate:Nbt: Either a block identifier or an object.
- Template:Nbt: A molang expression representing the tags of the target blocks.
- Template:NbtTemplate:Nbt: Either a block identifier or an object.
- Template:Nbt: Which states to enable. Valid values are Template:Cd.
Example:
<syntaxhighlight lang=json copy> "traits": {
"minecraft:placement_direction": {
"enabled_states": ["minecraft:corner_and_cardinal_direction"],
"blocks_to_corner_with": [{"tags": "q.any_tag('minecraft:cornerable_stairs')"}]
}
} </syntaxhighlight>
History
Template:Navbox Bedrock Edition
pt:Definição de bloco