Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Block definition: Difference between revisions

From SAS Gaming Wiki
SyncBot (talk | contribs)
Sync: updated from Minecraft
SyncBot (talk | contribs)
Sync: updated from Minecraft
 
(One intermediate revision by the same user not shown)
Line 19: Line 19:
****** {{nbt|boolean|is_hidden_in_commands}}: Whether or not the block is hidden from commands.
****** {{nbt|boolean|is_hidden_in_commands}}: Whether or not the block is hidden from commands.
***** [[#States|{{nbt|compound|states}}]]: Definitions of custom block state names and their possible values.
***** [[#States|{{nbt|compound|states}}]]: Definitions of custom block state names and their possible values.
***** [[#Traits|{{nbt|compound|traits}}]]: The block traits to enable, which provide access to specific vanilla states.
***** [[#Traits|{{nbt|compound|traits}}]]: The block traits to enable, which provide access to specific vanilla states and their behavior.
**** {{nbt|compound|components}}: The block's [[Minecraft:block components|components]]. This defines the block's behavior and visuals.
**** {{nbt|compound|components}}: The block's [[Minecraft:block components|components]]. This defines the block's behavior and visuals.
**** {{nbt|list|permutations}}: The block's permutations, which allow for components to be added only under certain conditions.
**** {{nbt|list|permutations}}: The block's permutations, which allow for components to be added only under certain conditions.
Line 48: Line 48:
=== Traits ===
=== Traits ===
The {{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 {{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 one or more traits and their enabled states:


====<code>minecraft:connection</code>====
====<code>minecraft:connection</code>====
{{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 {{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.
Gives blocks the boolean states {{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.


Line 71: Line 69:


==== <code>minecraft:multi_block</code> ====
==== <code>minecraft:multi_block</code> ====
{{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 {{cd|minecraft:multi_block_part}} state, which is an integer representing which part this block is in the multi block.
Allows a block to be made up of multiple block parts like a [[Minecraft:door]]. This adds the {{cd|minecraft:multi_block_part}} state, which is an integer representing which part this block is in the multi block.
Line 79: Line 76:
** {{nbt|list|enabled_states}}: Which states to enable. The only valid value is {{cd|minecraft:multi_block_part}}.
** {{nbt|list|enabled_states}}: Which states to enable. The only valid value is {{cd|minecraft:multi_block_part}}.
** {{nbt|integer|parts}}: The number of parts that this multi block should have. The value must be between 2 and 4, inclusive.
** {{nbt|integer|parts}}: The number of parts that this multi block should have. The value must be between 2 and 4, inclusive.
** {{nbt|string|direction}}: The direction to place the parts of the multi block in. Can be either {{cd|up|down|d=or}}.
** {{nbt|string|direction}}: The direction to place the parts of the multi block in. Can be:
*** {{cd|up}}
*** {{cd|down}}
*** {{cd|north}}{{OnlyExperimental|Upcoming Creator Features}}
*** {{cd|south}}{{OnlyExperimental|Upcoming Creator Features}}
*** {{cd|east}}{{OnlyExperimental|Upcoming Creator Features}}
*** {{cd|west}}{{OnlyExperimental|Upcoming Creator Features}}
</div>
</div>


Line 122: Line 125:
* <code>minecraft:cardinal_direction</code>: The direction the player was facing when the block was placed. Possible values are {{cd|north|south|east|west|d=and}}.
* <code>minecraft:cardinal_direction</code>: The direction the player was facing when the block was placed. Possible values are {{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 {{cd|up|down|east|north|west|south|d=and}}.
* <code>minecraft:facing_direction</code>: Same as <code>minecraft:cardinal_direction</code>, but allows up and down as well. Possible values are {{cd|up|down|east|north|west|south|d=and}}.
* <code>minecraft:sixteen_way_rotation</code>{{OnlyExperimental|Upcoming Creator Features}}: Same as <code>minecraft:cardinal_direction</code>, but has sixteen possible directions, and is stored as a number from 0-15 (inclusive).
* <code>minecraft:corner</code>: Allows the block to form corners with other blocks like stairs. Possible values are {{cd|none|inner_left|inner_right|outer_left|outer_right|d=and}}.
* <code>minecraft:corner</code>: Allows the block to form corners with other blocks like stairs. Possible values are {{cd|none|inner_left|inner_right|outer_left|outer_right|d=and}}.


<div class="treeview">
<div class="treeview">
* {{nbt|compound|minecraft:placement_direction}}
* {{nbt|compound|minecraft:placement_direction}}
** {{nbt|list|enabled_states}}: Which states to enable. Valid values are {{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.
** {{nbt|list|enabled_states}}: Which states to enable. Valid values are {{cd|minecraft:cardinal_direction|minecraft:facing_direction|minecraft:sixteen_way_rotation|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.
** {{nbt|float|y_rotation_offset}}: The offset to apply to the y rotation of the block. Can be {{cd|0.0|90.0|180.0|270.0|d=or}}.
** {{nbt|float|y_rotation_offset}}: The offset to apply to the y rotation of the block. Can be {{cd|0.0|90.0|180.0|270.0|d=or}}.
** {{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>.
** {{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>. Requires {{cd|enabled_states}} to include {{cd|minecraft:corner_and_cardinal_direction}}.
*** {{nbt|string}}{{nbt|compound}}: Either a block identifier or an object.
*** {{nbt|string}}{{nbt|compound}}: Either a block identifier or an object.
**** {{nbt|string|tags}}: A molang expression representing the tags of the target blocks.
**** {{nbt|string|tags}}: A molang expression representing the tags of the target blocks.
Line 167: Line 171:
|{{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.}}
|{{HistoryLine||26.10|dev=Preview 26.10.23|exp=Upcoming Creator Features|Added the {{cd|minecraft:multi_block}} block trait.}}
|{{HistoryLine||26.10|dev=Preview 26.10.23|exp=Upcoming Creator Features|Added the {{cd|minecraft:multi_block}} block trait.}}
|{{HistoryLine||26.20|dev=Preview 26.20.23|The {{cd|minecraft:multi_block}} block trait no longer requires the Upcoming Creator Features experiment in format version 1.26.20+, however this is a bug.}}
|{{HistoryLine||26.20|dev=Preview 26.20.20|The {{cd|menu_category}} object can no longer have an empty {{cd|group}} value. {{cd|group}} must either exist with a value or not exist at all.|The {{cd|category}} field of {{cd|menu_category}} is now required when {{cd|menu_category}} is used.|{{cd|blocks_to_corner_with}} now requires {{cd|minecraft:corner_and_cardinal_direction}} to be one of the {{cd|enabled_states}} for the {{cd|minecraft:placement_direction}} trait.}}
|{{HistoryLine|||dev=Preview 26.20.23|The {{cd|minecraft:multi_block}} block trait no longer requires the Upcoming Creator Features experiment in format version 1.26.20+, however this is a bug.}}
|{{HistoryLine||26.30|dev=Preview 26.30.28|exp=Upcoming Creator Features|Added the {{cd|minecraft:sixteen_way_rotation}} state as an available state for the {{cd|minecraft:placement_direction}} trait.}}
|{{HistoryLine||26.40|dev=Preview 26.40.22|Released the {{cd|minecraft:multi_block}} trait. Horizontal directions still require Upcoming Creator Features.}}
|{{HistoryLine||26.40|dev=Preview 26.40.27|exp=Upcoming Creator Features|Added support for {{cd|y_rotation_offset}} when using the {{cd|minecraft:sixteen_way_rotation}} placement direction block trait.|Added horizontal {{cd|direction}} support for the {{cd|minecraft:multi_block}} trait}}
}}
}}



Latest revision as of 11:08, 28 June 2026

Template: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:


States

The Template:Nbt object is used to define custom Minecraft: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 one or more 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.

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.

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.

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 as minecraft:cardinal_direction, but allows up and down as well. Possible values are Template:Cd.
  • minecraft:sixteen_way_rotationTemplate:OnlyExperimental: Same as minecraft:cardinal_direction, but has sixteen possible directions, and is stored as a number from 0-15 (inclusive).
  • minecraft:corner: Allows the block to form corners with other blocks like stairs. Possible 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:HistoryTable

Navigation

Template:Navbox Bedrock Edition

Minecraft:pt:Definição de bloco