Minecraft:Block definition: Difference between revisions
More actions
Remove broken links to missing pages |
Fix template calls: add MC/ prefix |
||
| Line 1: | Line 1: | ||
{{Exclusive|bedrock}} | {{MC/Exclusive|bedrock}} | ||
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 {{file|directory|blocks|inline=1}} folder of a [[Minecraft:behavior pack]]. | 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 {{file|directory|blocks|inline=1}} folder of a [[Minecraft:behavior pack]]. | ||
| Line 7: | Line 7: | ||
<div class="treeview"> | <div class="treeview"> | ||
* {{ | * {{MC/Nbt|compound}} | ||
** {{ | ** {{MC/Nbt|string|format_version}}: The format version of the file. This is a string representing a {{MC/BE}} version. It is recommended to use the latest version. For 26.0 and later, add a leading 1. For example: {{MC/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 {{MC/Cd|"1.26.0"}}). | ||
** {{ | ** {{MC/Nbt|boolean|use_beta_features}}: Whether or not this block is using beta features. | ||
** {{ | ** {{MC/Nbt|compound|minecraft:block}}: The block definition. | ||
*** {{ | *** {{MC/Nbt|compound|description}}: The technical definition of the block. | ||
**** {{ | **** {{MC/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. | ||
**** {{ | **** {{MC/Nbt|compound|menu_category}}: Defines where the block is located in the [[Minecraft:creative inventory]] and recipe book. | ||
***** {{ | ***** {{MC/Nbt|string|category}}: The inventory tab to put the block under. Can be {{MC/Cd|construction|equipment|items|nature|none|d=or}}. If omitted or {{MC/Cd|none}}, the block will not appear in the creative inventory or recipe book. | ||
***** {{ | ***** {{MC/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"> | ||
****** {{ | ****** {{MC/Cd|d=list|list-level=******|minecraft:itemGroup.name.anvil|minecraft:itemGroup.name.arrow|minecraft:itemGroup.name.axe|minecraft:itemGroup.name.banner|minecraft:itemGroup.name.banner_pattern|minecraft:itemGroup.name.bars|minecraft:itemGroup.name.bed|minecraft:itemGroup.name.boat|minecraft:itemGroup.name.boots|minecraft:itemGroup.name.bundles|minecraft:itemGroup.name.buttons|minecraft:itemGroup.name.candles|minecraft:itemGroup.name.chains|minecraft:itemGroup.name.chalkboard|minecraft:itemGroup.name.chest|minecraft:itemGroup.name.chestboat|minecraft:itemGroup.name.chestplate|minecraft:itemGroup.name.compounds|minecraft:itemGroup.name.concrete|minecraft:itemGroup.name.concretePowder|minecraft:itemGroup.name.cookedFood|minecraft:itemGroup.name.copper|minecraft:itemGroup.name.copper_golem_statue|minecraft:itemGroup.name.coral|minecraft:itemGroup.name.coral_decorations|minecraft:itemGroup.name.crop|minecraft:itemGroup.name.door|minecraft:itemGroup.name.dye|minecraft:itemGroup.name.enchantedBook|minecraft:itemGroup.name.fence|minecraft:itemGroup.name.fenceGate|minecraft:itemGroup.name.firework|minecraft:itemGroup.name.fireworkStars|minecraft:itemGroup.name.flower|minecraft:itemGroup.name.glass|minecraft:itemGroup.name.glassPane|minecraft:itemGroup.name.glazedTerracotta|minecraft:itemGroup.name.goatHorn|minecraft:itemGroup.name.grass|minecraft:itemGroup.name.hanging_sign|minecraft:itemGroup.name.harnesses|minecraft:itemGroup.name.helmet|minecraft:itemGroup.name.hoe|minecraft:itemGroup.name.horseArmor|minecraft:itemGroup.name.lanterns|minecraft:itemGroup.name.leaves|minecraft:itemGroup.name.leggings|minecraft:itemGroup.name.lightning_rod|minecraft:itemGroup.name.lingeringPotion|minecraft:itemGroup.name.log|minecraft:itemGroup.name.minecart|minecraft:itemGroup.name.miscFood|minecraft:itemGroup.name.mobEgg|minecraft:itemGroup.name.monsterStoneEgg|minecraft:itemGroup.name.mushroom|minecraft:itemGroup.name.nautilus_armor|minecraft:itemGroup.name.netherWartBlock|minecraft:itemGroup.name.ominousBottle|minecraft:itemGroup.name.ore|minecraft:itemGroup.name.permission|minecraft:itemGroup.name.pickaxe|minecraft:itemGroup.name.planks|minecraft:itemGroup.name.potion|minecraft:itemGroup.name.potterySherds|minecraft:itemGroup.name.pressurePlate|minecraft:itemGroup.name.products|minecraft:itemGroup.name.rail|minecraft:itemGroup.name.rawFood|minecraft:itemGroup.name.record|minecraft:itemGroup.name.sandstone|minecraft:itemGroup.name.sapling|minecraft:itemGroup.name.sculk|minecraft:itemGroup.name.seed|minecraft:itemGroup.name.shelf|minecraft:itemGroup.name.shovel|minecraft:itemGroup.name.shulkerBox|minecraft:itemGroup.name.sign|minecraft:itemGroup.name.skull|minecraft:itemGroup.name.slab|minecraft:itemGroup.name.smithing_templates|minecraft:itemGroup.name.spear|minecraft:itemGroup.name.splashPotion|minecraft:itemGroup.name.stainedClay|minecraft:itemGroup.name.stairs|minecraft:itemGroup.name.stone|minecraft:itemGroup.name.stoneBrick|minecraft:itemGroup.name.sword|minecraft:itemGroup.name.trapdoor|minecraft:itemGroup.name.walls|minecraft:itemGroup.name.wood|minecraft:itemGroup.name.wool|minecraft:itemGroup.name.woolCarpet}}</div> | ||
****** {{ | ****** {{MC/Nbt|boolean|is_hidden_in_commands}}: Whether or not the block is hidden from commands. | ||
***** [[#States|{{ | ***** [[#States|{{MC/Nbt|compound|states}}]]: Definitions of custom block state names and their possible values. | ||
***** [[#Traits|{{ | ***** [[#Traits|{{MC/Nbt|compound|traits}}]]: The block traits to enable, which provide access to specific vanilla states. | ||
**** {{ | **** {{MC/Nbt|compound|components}}: The block's [[Minecraft:block components|components]]. This defines the block's behavior and visuals. | ||
**** {{ | **** {{MC/Nbt|list|permutations}}: The block's permutations, which allow for components to be added only under certain conditions. | ||
***** {{ | ***** {{MC/Nbt|compound}}: ''A permutation'' | ||
****** {{ | ****** {{MC/Nbt|string|condition}}: The condition when this permutation's components should be active. This should be a [[Minecraft:molang]] expression resulting in a boolean. | ||
****** {{ | ****** {{MC/Nbt|compound|components}}: The [[Minecraft:block components|components]] that should be active when the {{MC/Cd|condition}} is true. | ||
</div> | </div> | ||
=== States === | === States === | ||
The {{ | The {{MC/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 47: | Line 47: | ||
=== Traits === | === Traits === | ||
The {{ | The {{MC/Nbt|compound|traits}} 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: | The object consists of traits and their enabled states: | ||
| Line 53: | Line 53: | ||
{{Warning|This trait is not compatible with Multiplayer; using it will make it impossible for players to enter your world see {{bug|MCPE-235104}}.}} | {{Warning|This trait is not compatible with Multiplayer; using it will make it impossible for players to enter your world see {{bug|MCPE-235104}}.}} | ||
Gives blocks the boolean states {{ | Gives blocks the boolean states {{MC/Cd|minecraft:connection_north|minecraft:connection_south|minecraft:connection_east|minecraft:connection_west|d=and}}, allowing for the block to connect to blocks next to it. | ||
<div class="treeview"> | <div class="treeview"> | ||
* {{ | * {{MC/Nbt|compound|minecraft:connection}} | ||
** {{ | ** {{MC/Nbt|list|enabled_states}}: Which states to enable. The only valid value is <code>minecraft:cardinal_connections</code>. | ||
</div> | </div> | ||
| Line 71: | Line 71: | ||
==== <code>minecraft:multi_block</code> ==== | ==== <code>minecraft:multi_block</code> ==== | ||
{{Experimental|be|be=Upcoming Creator Features|section=1}} | {{MC/Experimental|be|be=Upcoming Creator Features|section=1}} | ||
Allows a block to be made up of multiple block parts like a [[Minecraft:door]]. This adds the {{ | Allows a block to be made up of multiple block parts like a [[Minecraft:door]]. This adds the {{MC/Cd|minecraft:multi_block_part}} state, which is an integer representing which part this block is in the multi block. | ||
<div class="treeview"> | <div class="treeview"> | ||
* {{ | * {{MC/Nbt|compound|minecraft:multi_block}} | ||
** {{ | ** {{MC/Nbt|list|enabled_states}}: Which states to enable. The only valid value is {{MC/Cd|minecraft:multi_block_part}}. | ||
** {{ | ** {{MC/Nbt|integer|parts}}: The number of parts that this multi block should have. The value must be between 2 and 4, inclusive. | ||
** {{ | ** {{MC/Nbt|string|direction}}: The direction to place the parts of the multi block in. Can be either {{MC/Cd|up|down|d=or}}. | ||
</div> | </div> | ||
| Line 99: | Line 99: | ||
Gives blocks states related to where the player places the block. Two states are available: | Gives blocks states related to where the player places the block. Two states are available: | ||
* <code>minecraft:vertical_half</code>: The half of the block space that the block was placed in, allowing for stair and slab functionality. Possible values are {{ | * <code>minecraft:vertical_half</code>: The half of the block space that the block was placed in, allowing for stair and slab functionality. Possible values are {{MC/Cd|top|bottom|d=and}}. | ||
* <code>minecraft:block_face</code>: The block face that the player placed the block on, allowing for log and pillar functionality. Possible values are {{ | * <code>minecraft:block_face</code>: The block face that the player placed the block on, allowing for log and pillar functionality. Possible values are {{MC/Cd|up|down|east|north|west|south|d=and}}. | ||
<div class="treeview"> | <div class="treeview"> | ||
* {{ | * {{MC/Nbt|compound|minecraft:placement_position}} | ||
** {{ | ** {{MC/Nbt|list|enabled_states}}: Which states to enable. Valid values are {{MC/Cd|minecraft:vertical_half|minecraft:block_face|d=and}}. | ||
</div> | </div> | ||
| Line 120: | Line 120: | ||
Gives blocks states related to the direction in which the player places the block. Three states are available: | Gives blocks states related to the direction in which the player places the block. Three states are available: | ||
* <code>minecraft:cardinal_direction</code>: The direction the player was facing when the block was placed. Possible values are {{ | * <code>minecraft:cardinal_direction</code>: The direction the player was facing when the block was placed. Possible values are {{MC/Cd|north|south|east|west|d=and}}. | ||
* <code>minecraft:facing_direction</code>: Same as <code>minecraft:cardinal_direction</code>, but allows up and down as well. Possible values are {{ | * <code>minecraft:facing_direction</code>: Same as <code>minecraft:cardinal_direction</code>, but allows up and down as well. Possible values are {{MC/Cd|up|down|east|north|west|south|d=and}}. | ||
* <code>minecraft:corner</code>: Allows the block to form corners with other blocks like stairs. Possible values are {{ | * <code>minecraft:corner</code>: Allows the block to form corners with other blocks like stairs. Possible values are {{MC/Cd|none|inner_left|inner_right|outer_left|outer_right|d=and}}. | ||
<div class="treeview"> | <div class="treeview"> | ||
* {{ | * {{MC/Nbt|compound|minecraft:placement_direction}} | ||
** {{ | ** {{MC/Nbt|list|enabled_states}}: Which states to enable. Valid values are {{MC/Cd|minecraft:cardinal_direction|minecraft:facing_direction|minecraft:corner_and_cardinal_direction|d=and}}. <code>minecraft:corner_and_cardinal_direction</code> enables both the <code>minecraft:cardinal_direction</code> and <code>minecraft:corner</code> states. | ||
** {{ | ** {{MC/Nbt|float|y_rotation_offset}}: The offset to apply to the y rotation of the block. Can be {{MC/Cd|0.0|90.0|180.0|270.0|d=or}}. | ||
** {{ | ** {{MC/Nbt|list|blocks_to_corner_with}}: A list of blocks (or [[Minecraft:Block tag (Bedrock Edition)|block tags]]) to consider for <code>minecraft:corner</code>. | ||
*** {{ | *** {{MC/Nbt|string}}{{MC/Nbt|compound}}: Either a block identifier or an object. | ||
**** {{ | **** {{MC/Nbt|string|tags}}: A molang expression representing the tags of the target blocks. | ||
</div> | </div> | ||
| Line 146: | Line 146: | ||
== History== | == History== | ||
{{HistoryTable | {{HistoryTable | ||
|{{HistoryLine|Bedrock}} | |{{MC/HistoryLine|Bedrock}} | ||
|{{HistoryLine||1.12.0|dev=beta 1.12.0.2|Block definition was added with {{ | |{{HistoryLine||1.12.0|dev=beta 1.12.0.2|Block definition was added with {{MC/Cd|identifier}} defines the identifier of the block. Must have a namespace that isn't {{MC/Cd|minecraft}}, {{MC/Cd|is_experimental}} only registers the block if the {{MC/Cd|Use Experimental Gameplay}} toggle is enabled in world settings and {{MC/Cd|register_to_creative_menu}} causes the block to appear in the {{MC/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 {{ | |{{HistoryLine||1.16.100|Removed {{MC/Cd|is_experimental}} and {{MC/Cd|register_to_creative_menu}}.}} | ||
|{{HistoryLine||1.16.100|dev=beta 1.16.100.56|exp=Holiday Creator Features|Added field {{ | |{{HistoryLine||1.16.100|dev=beta 1.16.100.56|exp=Holiday Creator Features|Added field {{MC/Cd|events}} with {{MC/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.210|dev=beta 1.16.210.56|exp=Holiday Creator Features|Updated {{ | |{{HistoryLine||1.16.210|dev=beta 1.16.210.56|exp=Holiday Creator Features|Updated {{MC/Cd|decrement_stack}} response added {{MC/Cd|ignore_game_mode}} parameter which determines whether the stack will be decremented when the player is in creative mode.}} | ||
|{{HistoryLine||1.19.30|Added {{ | |{{HistoryLine||1.19.30|Added {{MC/Cd|menu_category}} with contains {{MC/Cd|category}} which determines which tab this block is placed into amd contains {{MC/Cd|group}} which determines which other items this block is grouped with.}} | ||
|{{HistoryLine||1.19.40|dev=Preview 1.19.40.21|Added flag {{ | |{{HistoryLine||1.19.40|dev=Preview 1.19.40.21|Added flag {{MC/Cd|is_hidden_in_commands}} in {{MC/Cd|menu_category}} to control whether or not a block can be used in commands.|{{MC/Cd|minecraft:direction}} is no longer exposed as a data-driven block property in properties. Blocks throw a content error when the {{MC/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.}} | |{{MC/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 {{ | |{{HistoryLine||1.20.0|dev=Preview 1.20.0.20|exp=Upcoming Creator Features|Added experimental support for {{MC/Cd|BlockTraits}} in block JSON with field {{MC/Cd|traits}}. {{MC/Cd|BlockTraits}} are a shortcut for creators to add vanilla block states and setter functions to data-driven blocks. Can parse {{MC/Cd|minecraft:placement_direction}} with the only available value being {{MC/Cd|minecraft:cardinal_direction}}.}} | ||
|{{HistoryLine|||dev=Preview 1.20.0.21|Added the {{ | |{{HistoryLine|||dev=Preview 1.20.0.21|Added the {{MC/Cd|minecraft:facing_direction}} to the {{MC/Cd|minecraft:placement_direction}}.}} | ||
|{{HistoryLine|||dev=Preview 1.20.0.22|Changed {{ | |{{HistoryLine|||dev=Preview 1.20.0.22|Changed {{MC/Cd|minecraft:cardinal_direction}} and {{MC/Cd|minecraft:facing_direction}} states from int to string type. {{MC/Cd|minecraft:cardinal_direction}} has four values {{MC/Cd|["north", "south", "east", "west"]}} and {{MC/Cd|minecraft:facing_direction}} has six values {{MC/Cd|["down", "up", "north", "south", "east", "west"]}}.}} | ||
|{{HistoryLine|||dev=Preview 1.20.0.23|Added the trait {{ | |{{HistoryLine|||dev=Preview 1.20.0.23|Added the trait {{MC/Cd|minecraft:placement_position}} with {{MC/Cd|minecraft:block_face}} is a six value string state ({{MC/Cd|down}}, {{MC/Cd|up}}, {{MC/Cd|north}}, {{MC/Cd|south}}, {{MC/Cd|east}}, {{MC/Cd|west}}) that contains info on which block face the player clicked on when the block was placed and {{MC/Cd|minecraft:vertical_half}} is a 2 value string state ({{MC/Cd|bottom}}, {{MC/Cd|top}}) with info on whether the block was placed in the lower or upper half of the block position.}} | ||
|{{HistoryLine||1.20.10|dev=Preview 1.20.10.21|Renamed field {{ | |{{HistoryLine||1.20.10|dev=Preview 1.20.10.21|Renamed field {{MC/Cd|properties}} to {{MC/Cd|states}}.}} | ||
|{{HistoryLine||1.20.10|dev=Preview 1.20.10.21|exp=Holiday Creator Features|Renamed {{ | |{{HistoryLine||1.20.10|dev=Preview 1.20.10.21|exp=Holiday Creator Features|Renamed {{MC/Cd|set_block_property}} response to {{MC/Cd|set_block_state}}.}} | ||
|{{HistoryLine||1.20.30|dev=Preview 1.20.20.21|Moved traits with {{ | |{{HistoryLine||1.20.30|dev=Preview 1.20.20.21|Moved traits with {{MC/Cd|minecraft:placement_direction}} and {{MC/Cd|minecraft:placement_position}} block traits out of experimental. These traits can be used for blocks with {{MC/Cd|format_version}} 1.20.20 or bigger.}} | ||
|{{HistoryLine||1.21.20|dev=Preview 1.21.20.23|Removed the "Holiday Creator Features" experiment Because of this, {{ | |{{HistoryLine||1.21.20|dev=Preview 1.21.20.23|Removed the "Holiday Creator Features" experiment Because of this, {{MC/Cd|events}} were also removed.}} | ||
|{{HistoryLine||1.21.60|dev=Preview 1.21.60.23|Updated {{ | |{{HistoryLine||1.21.60|dev=Preview 1.21.60.23|Updated {{MC/Cd|menu_category}} and updated {{MC/Cd|group}} parameter to require a namespace e.g. {{MC/Cd|minecraft:itemGroup.name.concrete}}.}} | ||
|{{HistoryLine||1.21.130|dev=Preview 1.21.130.20|exp=Upcoming Creator Features|Added a new block trait, {{ | |{{HistoryLine||1.21.130|dev=Preview 1.21.130.20|exp=Upcoming Creator Features|Added a new block trait, {{MC/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 {{MC/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 {{ | |{{HistoryLine||1.21.130|dev=Preview 1.21.130.24|exp=Beta APIs|Added new {{MC/Cd|minecraft:corner_and_cardinal_direction}} to the {{MC/Cd|minecraft:placement_direction}} block trait, which enables the {{MC/Cd|minecraft:corner}} state with values {{MC/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 {{MC/Cd|use_beta_features}} flag on your block.}} | ||
|{{HistoryLine||26.0|dev=Preview 26.0.27|The Block Trait {{ | |{{HistoryLine||26.0|dev=Preview 26.0.27|The Block Trait {{MC/Cd|minecraft:connection}} can now be used without the Upcoming Creator Features toggle.|{{MC/Cd|minecraft:corner_and_cardinal_direction}} in {{MC/Cd|minecraft:placement_direction}} can now be used without the Beta APIs toggle.}} | ||
|{{HistoryLine||26.10|dev=Preview 26.10.23|exp=Upcoming Creator Features|Added the {{ | |{{HistoryLine||26.10|dev=Preview 26.10.23|exp=Upcoming Creator Features|Added the {{MC/Cd|minecraft:multi_block}} block trait.}} | ||
}} | }} | ||
== Navigation == | == Navigation == | ||
{{Navbox Bedrock Edition}} | {{MC/Navbox Bedrock Edition}} | ||
pt:Definição de bloco | pt:Definição de bloco | ||
Latest revision as of 19:54, 9 April 2026
Script error: No such module "Exclusive".
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/sprite
- Template:Nbt/sprite format_version: The format version of the file. This is a string representing a Bedrock Edition version. It is recommended to use the latest version. For 26.0 and later, add a leading 1. For example:
- REDIRECT Template:Code
Template:Redr for 26.0. Preview versions should use the version that it is a preview for (Example: Preview 26.0.27 would be
- REDIRECT Template:Code
- Template:Nbt/sprite use_beta_features: Whether or not this block is using beta features.
- Template:Nbt/sprite minecraft:block: The block definition.
- Template:Nbt/sprite description: The technical definition of the block.
- Template:Nbt/sprite 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.
- Template:Nbt/sprite menu_category: Defines where the block is located in the Minecraft:creative inventory and recipe book.
- Template:Nbt/sprite category: The inventory tab to put the block under. Can be
- Template:Nbt/sprite description: The technical definition of the block.
- REDIRECT Template:Code
Template:Redr. If omitted or
- REDIRECT Template:Code
Template:Redr, the block will not appear in the creative inventory or recipe book.
- Template:Nbt/sprite group: The creative inventory group to add the block to. Custom groups can be added via the Template:File. Vanilla groups are:
- Template:Nbt/sprite group: The creative inventory group to add the block to. Custom groups can be added via the Template:File. Vanilla groups are:
- REDIRECT Template:Code
- Template:Nbt/sprite is_hidden_in_commands: Whether or not the block is hidden from commands.
- [[#States|Template:Nbt/sprite states]]: Definitions of custom block state names and their possible values.
- [[#Traits|Template:Nbt/sprite traits]]: The block traits to enable, which provide access to specific vanilla states.
- Template:Nbt/sprite components: The block's components. This defines the block's behavior and visuals.
- Template:Nbt/sprite permutations: The block's permutations, which allow for components to be added only under certain conditions.
- Template:Nbt/sprite: A permutation
- Template:Nbt/sprite condition: The condition when this permutation's components should be active. This should be a Minecraft:molang expression resulting in a boolean.
- Template:Nbt/sprite components: The components that should be active when the
- Template:Nbt/sprite: A permutation
- REDIRECT Template:Code
Template:Redr is true.
States
The Template:Nbt/sprite 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 "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/sprite traits 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
- REDIRECT Template:Code
Template:Redr, allowing for the block to connect to blocks next to it.
- Template:Nbt/sprite minecraft:connection
- Template:Nbt/sprite enabled_states: Which states to enable. The only valid value is
minecraft:cardinal_connections.
- Template:Nbt/sprite enabled_states: 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
Template:Message boxTemplate:Article other
Allows a block to be made up of multiple block parts like a Minecraft:door. This adds the
- REDIRECT Template:Code
Template:Redr state, which is an integer representing which part this block is in the multi block.
- Template:Nbt/sprite minecraft:multi_block
- Template:Nbt/sprite enabled_states: Which states to enable. The only valid value is
- REDIRECT Template:Code
- Template:Nbt/sprite parts: The number of parts that this multi block should have. The value must be between 2 and 4, inclusive.
- Template:Nbt/sprite direction: The direction to place the parts of the multi block in. Can be either
- REDIRECT Template:Code
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
- REDIRECT Template:Code
minecraft:block_face: The block face that the player placed the block on, allowing for log and pillar functionality. Possible values are
- REDIRECT Template:Code
- Template:Nbt/sprite minecraft:placement_position
- Template:Nbt/sprite enabled_states: Which states to enable. Valid values are
- REDIRECT Template:Code
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
- REDIRECT Template:Code
minecraft:facing_direction: Same asminecraft:cardinal_direction, but allows up and down as well. Possible values are
- REDIRECT Template:Code
minecraft:corner: Allows the block to form corners with other blocks like stairs. Possible values are
- REDIRECT Template:Code
- Template:Nbt/sprite minecraft:placement_direction
- Template:Nbt/sprite enabled_states: Which states to enable. Valid values are
- REDIRECT Template:Code
Template:Redr. minecraft:corner_and_cardinal_direction enables both the minecraft:cardinal_direction and minecraft:corner states.
- Template:Nbt/sprite y_rotation_offset: The offset to apply to the y rotation of the block. Can be
- REDIRECT Template:Code
- Template:Nbt/sprite blocks_to_corner_with: A list of blocks (or block tags) to consider for
minecraft:corner.- Template:Nbt/spriteTemplate:Nbt/sprite: Either a block identifier or an object.
- Template:Nbt/sprite tags: A molang expression representing the tags of the target blocks.
- Template:Nbt/spriteTemplate:Nbt/sprite: Either a block identifier or an object.
- Template:Nbt/sprite blocks_to_corner_with: A list of blocks (or block tags) to consider for
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
pt:Definição de bloco