Custom Slabs

experimental

easy

PLEASE READ

This page will be part of a rewrite to accomodate for the removal of the Holiday Creator Feature experimental toggle. Expect this page to be rewritten or removed when this happens.

FORMAT & MIN ENGINE VERSION 1.20.60

This tutorial assumes a basic understanding of blocks. Check out the blocks guide before starting.

EXPERIMENTAL

Requires Holiday Creator Features to trigger block events and for use of the minecraft:unit_cube component.

Introduction

Making custom slabs is a simple task, but if you find any drawbacks during recreating slabs, this tutorial will help you with it, and you'll be provided with a template for you to use.

Issues:

  • Your custom slab will appear vertically centred when carried.
  • Your custom slab may appear full-sized in item form (on the ground, in item frames, in hand)

Custom Slab

This will create a vanilla-like custom slab.

BP/blocks/custom_slab.jsonCopy
json
{
  "format_version": "1.20.60",
  "minecraft:block": {
    "description": {
      "identifier": "wiki:custom_slab",
      "menu_category": {
        "category": "construction",
        "group": "itemGroup.name.slab"
      },
      "traits": {
        "minecraft:placement_position": {
          "enabled_states": ["minecraft:vertical_half"]
        }
      },
      "states": {
        "wiki:double": [false, true]
      }
    },
    "permutations": [
      // Bottom Slab
      {
        "condition": "q.block_state('minecraft:vertical_half') == 'bottom' && !q.block_state('wiki:double')",
        "components": {
          "minecraft:collision_box": {
            "origin": [-8, 0, -8],
            "size": [16, 8, 16]
          },
          "minecraft:selection_box": {
            "origin": [-8, 0, -8],
            "size": [16, 8, 16]
          },
          "minecraft:on_interact": {
            "event": "wiki:form_double",
            "condition": "q.block_face == 1.0 && q.is_item_name_any('slot.weapon.mainhand', 'wiki:custom_slab')"
          }
        }
      },
      // Top Slab
      {
        "condition": "q.block_state('minecraft:vertical_half') == 'top' && !q.block_state('wiki:double')",
        "components": {
          "minecraft:collision_box": {
            "origin": [-8, 8, -8],
            "size": [16, 8, 16]
          },
          "minecraft:selection_box": {
            "origin": [-8, 8, -8],
            "size": [16, 8, 16]
          },
          "minecraft:on_interact": {
            "event": "wiki:form_double",
            "condition": "q.block_face == 0.0 && q.is_item_name_any('slot.weapon.mainhand', 'wiki:custom_slab')"
          }
        }
      },
      // Double Slab
      {
        "condition": "q.block_state('wiki:double')",
        "components": {
          "minecraft:unit_cube": {},
          "minecraft:on_player_destroyed": {
            "event": "wiki:destroy_double"
          }
        }
      }
    ],
    "components": {
      "minecraft:destructible_by_mining": {
        "seconds_to_destroy": 7
      },
      "minecraft:destructible_by_explosion": {
        "explosion_resistance": 6
      },
      "minecraft:geometry": {
        "identifier": "geometry.slab",
        "bone_visibility": {
          "bottom_slab": "q.block_state('minecraft:vertical_half') == 'bottom'",
          "top_slab": "q.block_state('minecraft:vertical_half') == 'top'"
        }
      },
      "minecraft:material_instances": {
        "*": {
          "texture": "stone"
        }
      }
    },
    "events": {
      "wiki:form_double": {
        "set_block_state": {
          "wiki:double": true
        },
        "run_command": {
          "command": "playsound use.stone @a ~~~ 1 0.8"
        },
        "decrement_stack": {}
      },
      "wiki:destroy_double": {
        "spawn_loot": {} // Spawns the block's default loot
      }
    }
  }
}
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102

Geometry

This will be the geometry used for your custom slabs.

Geometry JSON
RP/models/blocks/slab.geo.jsonCopy
json
{
  "format_version": "1.12.0",
  "minecraft:geometry": [
    {
      "description": {
        "identifier": "geometry.slab",
        "texture_width": 16,
        "texture_height": 16,
        "visible_bounds_width": 2,
        "visible_bounds_height": 2.5,
        "visible_bounds_offset": [0, 0.75, 0]
      },
      "bones": [
        {
          "name": "top_slab",
          "pivot": [0, 0, 0],
          "cubes": [
            {
              "origin": [-8, 8, -8],
              "size": [16, 8, 16],
              "uv": {
                "north": {"uv": [0, 0], "uv_size": [16, 8]},
                "east": {"uv": [0, 0], "uv_size": [16, 8]},
                "south": {"uv": [0, 0], "uv_size": [16, 8]},
                "west": {"uv": [0, 0], "uv_size": [16, 8]},
                "up": {"uv": [16, 16], "uv_size": [-16, -16]},
                "down": {"uv": [16, 16], "uv_size": [-16, -16]}
              }
            }
          ]
        },
        {
          "name": "bottom_slab",
          "pivot": [0, 0, 0],
          "cubes": [
            {
              "origin": [-8, 0, -8],
              "size": [16, 8, 16],
              "uv": {
                "north": {"uv": [0, 8], "uv_size": [16, 8]},
                "east": {"uv": [0, 8], "uv_size": [16, 8]},
                "south": {"uv": [0, 8], "uv_size": [16, 8]},
                "west": {"uv": [0, 8], "uv_size": [16, 8]},
                "up": {"uv": [16, 16], "uv_size": [-16, -16]},
                "down": {"uv": [16, 16], "uv_size": [-16, -16]}
              }
            }
          ]
        }
      ]
    }
  ]
}
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

Contributors