Rotatable Blocks

experimental

TIP

This tutorial assumes you have a basic understanding of blocks and Blockbench. Ensure to check out the blocks guide before starting this tutorial

First Steps

Make sure you have the Holiday Creator Features toggle turned on. This will allow us to utilize the 1.16.100 components.

The Model

Minecraft uses the default pivot points of [0,0,0]. This means that if your model consits of specific pivot points, your model will look detached in-game. In order to combat this, we can use the blockbench plugin called "Bedrock Pivot Fix 2". This will align your elements to the default pivot point without moving your elements.

Permutations

Rotating blocks make use of the permutations that were intoduced in 1.16.100. The each permutation contains the minecraft:rotation component, and when the condition is true, it will rotate the block to that direction.

BP/blocks/my_block.json#descriptionCopy
{
    "permutations": [
        {
            "condition": "query.block_property('wiki:rotation') == 2",
            "components": {
                "minecraft:rotation": [0, 0, 0]
            }
        },
        {
            "condition": "query.block_property('wiki:rotation') == 3",
            "components": {
                "minecraft:rotation": [0, 180, 0]
            }
        },
        {
            "condition": "query.block_property('wiki:rotation') == 4",
            "components": {
                "minecraft:rotation": [0, 90, 0]
            }
        },
        {
            "condition": "query.block_property('wiki:rotation') == 5",
            "components": {
                "minecraft:rotation": [0, 270, 0]
            }
        }
    ]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

Events

In order to make the block rotate the way the player is facing, we have to use some simple molang to query which way the player is facing.

BP/blocks/my_block.json#descriptionCopy
{
    "events": {
        "wiki:set_rotation": {
            "set_block_property": {
                "wiki:rotation": "(query.cardinal_facing_2d)"
            }
        }
    }
}
1
2
3
4
5
6
7
8
9

This event is called upon by using the minecraft:on_player_placing component.

BP/blocks/my_block.json#componentsCopy
{
    "minecraft:on_player_placing": {
        "event": "wiki:set_rotation"
    }
}
1
2
3
4
5

The Block Code

BP/blocks/my_block.jsonCopy
{
	"format_version": "1.16.100",
	"minecraft:block": {
		"description": {
			"identifier": "wiki:cabinet",
			"properties": {
				"wiki:rotation": [2, 3, 4, 5]
			}
		},
		"events": {
			"wiki:set_rotation": {
				"set_block_property": {
					"wiki:rotation": "(query.cardinal_facing_2d)"
				}
			}
		},
		"components": {
			"minecraft:material_instances": {
				"*": {
					"texture": "cabinet",
					"render_method": "alpha_test"
				}
			},
			"minecraft:pick_collision": {
				"origin": [-8, 0, -8],
				"size": [16, 16, 16]
			},
			"minecraft:entity_collision": {
				"origin": [-8, 0, -8],
				"size": [16, 16, 16]
			},
			"minecraft:geometry": "geometry.cabinet",
			"minecraft:block_light_absorption": 0,
			"minecraft:destroy_time": 3,
			"minecraft:on_player_placing": {
				"event": "wiki:set_rotation"
			}
		},
		"permutations": [{
				"condition": "query.block_property('wiki:rotation') == 2",
				"components": {
					"minecraft:rotation": [0, 0, 0]
				}
			},
			{
				"condition": "query.block_property('wiki:rotation') == 3",
				"components": {
					"minecraft:rotation": [0, 180, 0]
				}
			},
			{
				"condition": "query.block_property('wiki:rotation') == 4",
				"components": {
					"minecraft:rotation": [0, 90, 0]
				}
			},
			{
				"condition": "query.block_property('wiki:rotation') == 5",
				"components": {
					"minecraft:rotation": [0, 270, 0]
				}
			}
		]
	}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

Contributors

MedicalJewel105ihategravel2SmokeyStackUltr4Anubis