Custom Blocks
materialThisThis is a startup script.
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()]
- material('material')
- type('basic') // See available types below
- hardness(float) // >= 0.0
- resistance(float) // >= 0.0
- unbreakable()
- lightLevel(int) // 0.0 - 1.0
- harvestTool('tool', level) // Available tools: pickaxe, axe, hoe, shovel, level >= 0
- opaque(boolean)
- fullBlock(boolean)
- requiresTool(boolean)
- renderType('type') // solid, cutout, translucent, cutout required for blocks with texture like glass, translucent required for blocks like stained glass
- color(tintindex, color)
- texture('texturepath')
- texture('side', 'texturepath')
- model('modelpath')
- noItem()
- box(x0, y0, z0, x1, y1, z1, true) // 0.0 - 16.0, default is (0,0,0,16,16,16, true)
- box(x0, y0, z0, x1, y1, z1, false) // Same as above, but in 0.0 - 1.0 scale, default is (0,0,0,1,1,1, false)
- noCollision()
- notSolid()
- waterlogged()
- noDrops()
- slipperiness(float) //
- speedFactor(float)
- jumpFactor(float)
- randomTick(randomTickEvent => {}) // see below
- item(itemBuilder => {})
- setLootTableJson(json)
- setBlockstateJson(json)
- setModelJson(json)
- noValidSpawns(boolean)
- suffocating(boolean)
- viewBlocking(boolean)
- redstoneConductor(boolean)
- transparent(boolean)
- defaultCutout() // batches a bunch of methods to make blocks such as glass
- defaultTranslucent() // similar to defaultCutout() but using translucent layer instead
- tag('forge:something') // adds a block tag
- tagBlockAndItem('forge:something') // adds both block and item tag
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