API
Block shapes
A block doesn't have to be a cube. You describe its shape as one or more boxes, and Crafting draws it, makes it solid and lets light and neighbouring faces through where it is not full. For a look of your own, give it a model.
Shape: a list of boxes
block "half" { shape: [[0, 0, 0, 16, 8, 16]] }
block "pedestal" {
shape: [[2, 0, 2, 14, 2, 14], [5, 2, 5, 11, 12, 11], [3, 12, 3, 13, 14, 13]]
}Each box is [x1, y1, z1, x2, y2, z2] in pixels, from 0 to 16 (16 is one whole block). The block is drawn with those boxes, with its texture on every face, and it collides with them: players stand on the boxes and the selection outline follows them.
Model: a look of your own
block "lamp" {
model: "block/lamp"
shape: [[7, 0, 7, 9, 12, 9], [5, 12, 5, 11, 16, 11]]
light: 15
}| Property | Values | Default |
|---|---|---|
shape |
list of boxes [x1, y1, z1, x2, y2, z2], in pixels (0–16) |
a full cube |
model |
path of a block model of the mod: block/lamp is the mod's models/block/lamp.json |
drawn from shape, or a cube |
The model is a standard block model in JSON, such as the ones a model editor exports. Textures it refers to are written as <mod id>:block/<name>. With shape as well, the shape is what the block collides with; without it, the block collides as a full cube.
Where the files go
| Mod | Where |
|---|---|
| CraftScript (folder) | mods/lamps/models/block/lamp.json, mods/lamps/textures/block/lamp.png |
| Kotlin or Java | src/main/resources/assets/lamps/models/block/lamp.json |
Shapes by state
shape_when gives a block boxes it has only in some of its states (see Block states in Blocks, items and recipes). Each key is "state=value"; in each state the block has the boxes of shape plus those of every key that matches.
block "stone_column" {
states: [{ part: ["single", "bottom", "top"] }]
shape: [[4, 0, 4, 12, 16, 12]]
shape_when: {
"part=single": [[2, 0, 2, 14, 2, 14], [2, 14, 2, 14, 16, 14]],
"part=bottom": [[2, 0, 2, 14, 2, 14]],
"part=top": [[2, 14, 2, 14, 16, 14]]
}
}Values are written as the state shows them: true or false for a toggle, a number, a name, or a direction such as north. The boxes are what the block collides with and what its outline follows; how it looks in each state comes from its textures or models for that state.
Good to know
- A block that isn't a cube lets light and the faces of its neighbours through by itself; you don't have to mark it as
transparent. - All the other block properties (
hardness,light,tool,loot…) work the same; see Blocks, items and recipes.
In Kotlin
block("half") { box(0, 0, 0, 16, 8, 16) }
block("lamp") {
model = "block/lamp"
box(7, 0, 7, 9, 12, 9)
box(5, 12, 5, 11, 16, 11)
light = 15
}Each box(x1, y1, z1, x2, y2, z2) adds a box; model is the same path as in CraftScript. boxWhen(state, value, x1, y1, z1, x2, y2, z2) adds a box for one state:
block("stone_column") {
choice("part", "single", "bottom", "top")
box(4, 0, 4, 12, 16, 12)
boxWhen("part", "bottom", 2, 0, 2, 14, 2, 14)
boxWhen("part", "top", 2, 14, 2, 14, 16, 14)
}