Custom Blocks
This is a startup script.
onEvent('block.registry', event => {
event.create('test_block')
.material('glass')
.hardness(0.5)
.displayName('Test Block') // No longer required in 1.18.2+
.tagBlock('minecraft:mineable/shovel') // Make it mine faster using a shovel in 1.18.2+
// Block with custom type (see below for list of types)
event.create('test_block_slab', 'slab').material('glass').hardness(0.5)
})
The texture for this block has to be placed in kubejs/assets/kubejs/textures/block/test_block.png.
If you want a custom block model, you can create one in Blockbench and put it in kubejs/assets/kubejs/models/block/test_block.json.
List of available materials - to change break/walk sounds and to change some properties.
| Materials (1.18.2) |
| air |
| wood |
| stone |
| metal |
| grass |
|
dirt |
| water |
| lava |
| leaves |
| plant |
| sponge |
| wool |
| sand |
| glass |
| explosive |
| ice |
| snow |
| clay |
| vegetable |
| dragon_egg |
| portal |
| cake |
| web |
| slime |
| honey |
| berry_bush |
| lantern |
Other methods block builder supports:
- displayName('name')
//- Not required for 1.18.2+
- See list above
- See available types below.
- Do not use for 1.18.2, use the syntax in the second example above
- >= 0.0
- >= 0.0
- Sets the resistance to MAX_VALUE and hardness to -1, like bedrock
- 0.0 - 1.0
- Available tools: pickaxe, axe, hoe,
shovel,shovel - level >= 0
- Not used in 1.18.2+, see tag in example above
- 0.0 - 16.
0,0 - default is (0,0,0,16,16,16, true)
- Same as above, but in 0.0 - 1.0
scale,scale - default is (0,0,0,1,1,1, false)
- see below
- batches a bunch of methods to make blocks such as glass
- similar to defaultCutout() but using translucent layer instead
- adds a block tag
- adds an item tag
- adds both block and item tag
Event callbacks:
RandomTickEvent:
- BlockContainerJS block
- Random random
- LevelJS getLevel()
- ServerJS getServer()
Types
- basic
- detector
- slab
- stairs
- fence
- fence_gate
- wall
- wooden_pressure_plate
- stone_pressure_plate
- wooden_button
- stone_button
- falling
- crop