Custom Blocks
This is a startup script.
onEvent('block.registry', event => {
event.create('test_block')
.material('glass')
.hardness(0.5)
})
// Or for a brief moment in 1.18.1
onEvent('block.registry', event => {
event.create('test_block', block => {
block.material('glass')
block.hardness(0.5)
block.displayName('Test Block')
})
})
// or, in KubeJS 3 for MC 1.16:
onEvent('block.registry', event => {
event.create('test_block')
.material('glass')
.hardness(0.5)
.displayName('Test Block')
})
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 (tool used to mine, etc):
| Material |
| air |
| wood |
| rock |
| iron |
| organic |
|
earth |
| water |
| lava |
| leaves |
| plants |
| sponge |
| wool |
| sand |
| glass |
| tnt |
| coral |
| ice |
| snow |
| clay |
| groud |
| dragon_egg |
| portal |
| cake |
| web |
| slime |
| honey |
| berry_bush |
| lantern |
Other methods block builder supports: [you can chain these methods after displayName()]methods]
Event callbacks:
RandomTickEvent:
- BlockContainerJS block
- Random random
Types
- basic
- slab
- stairs
- fence
- fence_gate
- wall
- wooden_pressure_plate
- stone_pressure_plate
- wooden_button
- stone_button