Block Traits
FORMAT & MIN ENGINE VERSION 1.21.40
Before you learn about block traits, you should be confident with block states.
When working with block states, ensure that the min_engine_version
in your pack manifest is 1.20.20
or higher.
Applying Traits
Block traits can be used to apply vanilla block states (such as direction) to your custom blocks easily, without the need for events and triggers.
{
"format_version": "1.21.40",
"minecraft:block": {
"description": {
"identifier": "wiki:custom_slab",
"menu_category": {
"category": "construction",
"group": "itemGroup.name.slab"
},
"traits": {
"minecraft:placement_position": {
"enabled_states": ["minecraft:vertical_half"]
}
}
},
"components": { ... },
"permutations": [ ... ]
}
}
This example will set the minecraft:vertical_half
block state when placed to either 'top'
or 'bottom'
- depending on where the player is looking.
Permutations are still required for this state to make a functional difference, with conditions querying
q.block_state('minecraft:vertical_half')
List of Traits
Placement Direction
Contains information about the player's rotation when the block was placed.
Released from experiment Upcoming Creator Features
for format versions 1.20.20 and higher.
Provided States
State | Values | Description |
---|---|---|
minecraft:cardinal_direction | "south" (default)"north" "west" "east" | Cardinal facing direction of player when placed. |
minecraft:facing_direction | "down" (default)"up" "south" "north" "west" "east" | Overall direction of player when placed. |
Additional Parameters
y_rotation_offset
- This rotation offset only applies to the horizontal state values (north, south, east, west) . Only axis-aligned angles may be specified (e.g. 90, 180, -90).
"minecraft:placement_direction": {
"enabled_states": ["minecraft:cardinal_direction"],
"y_rotation_offset": 180
}
Placement Position
Contains information about where the player placed the block.
Released from experiment Upcoming Creator Features
for format versions 1.20.20 and higher.
Provided States
State | Values | Description |
---|---|---|
minecraft:block_face | "down" (default)"up" "south" "north" "west" "east" | Face on which the block was placed. |
minecraft:vertical_half | "top" "bottom" (default) | The vertical half where the block was placed. |
"minecraft:placement_position": {
"enabled_states": [
"minecraft:block_face",
"minecraft:vertical_half"
]
}