14 KiB
Block Models
A block's model is its shape: the boxes it's made of and which texture goes on each face. Blocks use cubi:cube unless
they set model. For entity models, see Entities.
Built-In Models
| Model | Texture variables | Shape |
|---|---|---|
cubi:cube |
one texture, { top, bottom, side } or { front, side } |
A full block. |
cubi:cross |
cross |
Two crossed planes, like flowers and saplings. |
cubi:crop |
crop |
Four planes in a # shape, like wheat. |
Blocks that aren't full cubes should use the cutout or translucent render layer, since
solid blocks hide their neighbors' faces. They usually want "collision": false too.
In inventories, a block with a full cube model is drawn as a cube. Any other block is drawn flat, as its first texture,
like Minecraft's plants, unless it sets an item_model.
Texture Variables
Models name their textures with variables, like #side, and blocks fill them in with textures:
{
"id": "bworld:sapling",
"model": "cubi:cross",
"textures": { "cross": "bworld:sapling" }
}
For cubi:cube, one texture id fills every face. { "front", "side" } puts front on the north face and side on the
rest. It's for blocks that face a way, and can also set top and bottom.
Custom Models
Mods add models in models/, in Minecraft's block model format: boxes measured in pixels, where 0 to 16 is the block,
with a texture per face. models/slab.json:
{
"format_version": 1,
"model": {
"id": "copper_tools:slab",
"textures": { "top": "#side", "bottom": "#side" },
"elements": [{
"from": [0, 0, 0],
"to": [16, 8, 16],
"faces": {
"top": { "texture": "#top" },
"bottom": { "texture": "#bottom", "cullface": "bottom" },
"north": { "texture": "#side", "cullface": "north" },
"south": { "texture": "#side", "cullface": "south" },
"west": { "texture": "#side", "cullface": "west" },
"east": { "texture": "#side", "cullface": "east" }
}
}]
}
}
A block using it sets "model": "copper_tools:slab" and "textures": { "side": "bworld:oak_planks" }, and gets planks
on every face, since top and bottom default to #side.
| Field | Meaning |
|---|---|
id |
The model's id, in the mod's namespace. |
parent |
Another model this one starts from, see Parents. |
textures |
Defaults for texture variables. Values are texture ids or other variables, like "#side". |
elements[].from, to |
Opposite corners of the box, [x, y, z] in pixels. |
elements[].rotation |
{ origin, axis, angle, rescale }: turns the box around origin on x, y or z by angle degrees, from -180 to 180. rescale stretches it back to the block's width. |
elements[].shade |
Darker faces on the sides and bottom. true by default, plants turn it off. |
elements[].faces |
Any of top, bottom, north, south, west and east. |
faces.*.texture |
A variable like "#side", filled in by the block's textures, or a texture id. |
faces.*.uv |
[u1, v1, u2, v2], the part of the texture in pixels. Defaults to the part the face covers. |
faces.*.rotation |
Turns the texture on the face clockwise by 0, 90, 180 or 270 degrees. |
faces.*.cullface |
Hides the face when the neighbor on that side is a solid block. Only for faces on the block's edge. |
display |
Where an item drawn with this model is shown, and how, see Display Transforms. |
Faces are only drawn from the front, so a flat plane that should be seen from both sides needs a face each way.
Parents
A model can start from another with parent, like Minecraft's. It gets the parent's elements unless it has its own, and
the parent's texture defaults and display transforms, with its own winning. A parent can have a
parent too. models/brass_gear.json reuses a gear's shape with other textures:
{
"format_version": 1,
"model": {
"id": "copper_tools:brass_gear",
"parent": "copper_tools:gear",
"textures": { "teeth": "copper_tools:brass" }
}
}
A parent can be the mod's own model, a built-in one, or one from a mod it depends on. A model with no elements is only
there to be a parent, or to give its children texture defaults. Parents are merged in once, when the game loads, so a
model with a parent draws exactly as if it had everything written out. check-mods reports a parent that doesn't exist
and parents that loop.
The base game has Minecraft's template models in mods/bworld/models/templates/, with the same names and texture
variables: bworld:cube, cube_all, cube_column, cube_column_horizontal, cube_bottom_top, orientable,
orientable_with_bottom, slab, slab_top, stairs, inner_stairs, outer_stairs, the template_wall_* and
template_glass_pane_* models, and wall_inventory. A pillar from a log's textures:
{
"format_version": 1,
"model": {
"id": "copper_tools:pillar",
"parent": "bworld:cube_column",
"textures": { "end": "copper_tools:pillar_top", "side": "copper_tools:pillar" }
}
}
Shapes
A block's shape is the boxes it's made of, like Minecraft's VoxelShape. It's what players point at, so they can look
past the empty half of a slab, what the cracks are drawn on while it's being broken, and, unless the block sets
"collision": false, what entities bump into and stand on. A block that's only half there can't be placed where a
player is standing in its other half, either.
By default it comes from the model: one box per element, turned with the block's y. An element turned by its own
rotation gets the box around it. Elements that are flat planes aren't boxes, so a model made only of planes, like
cubi:cross and cubi:crop, gets one box around all of them, which is what players point at to break the plant.
A block can set its own with shape, a list of boxes in pixels like from and to put together, as Minecraft's
Block.box does. That's for a shape simpler than the model, or one that's different from what's drawn, like a flower
pot's plant you can't click on. shape is turned with the block's y too, and variants can set
their own, like a crop that's taller the older it is:
{
"id": "copper_tools:rice",
"model": "cubi:crop",
"textures": { "crop": "copper_tools:rice_3" },
"collision": false,
"states": [{ "name": "age", "bits": 2, "default": 0 }],
"shape": [[0, 0, 0, 16, 16, 16]],
"variants": {
"age=0": { "textures": { "crop": "copper_tools:rice_0" }, "shape": [[0, 0, 0, 16, 4, 16]] },
"age=1": { "textures": { "crop": "copper_tools:rice_1" }, "shape": [[0, 0, 0, 16, 8, 16]] },
"age=2": { "textures": { "crop": "copper_tools:rice_2" }, "shape": [[0, 0, 0, 16, 12, 16]] }
}
}
Boxes stay inside the block, from 0 to 16.
Collision Shapes
What entities bump into is the shape, unless the block sets collision_shape, like Minecraft's getCollisionShape.
It's in pixels like shape, and is the only shape that can go higher than the block: up to 24 pixels, so a fence is too
tall to jump over while players still point at a block-high post. Variants and parts can set their own.
Parts
A block can be made of pieces instead of one model, like Minecraft's multipart blockstates. Each of parts is a model
that's drawn when its when matches the block's states (always, without one), turned by its y.
Its shape and collision_shape are added to the block's when it's drawn. A fence is a post, and a bar for each side
it joins, blocks/oak_fence.json:
"states": [
{ "name": "north", "bits": 1, "default": 0 },
{ "name": "east", "bits": 1, "default": 0 },
{ "name": "south", "bits": 1, "default": 0 },
{ "name": "west", "bits": 1, "default": 0 }
],
"parts": [
{ "model": "bworld:fence_post", "shape": [[6, 0, 6, 10, 16, 10]], "collision_shape": [[6, 0, 6, 10, 24, 10]] },
{ "when": "north=1", "model": "bworld:fence_side", "shape": [[7, 0, 0, 9, 16, 9]], "collision_shape": [[7, 0, 0, 9, 24, 9]] },
{ "when": "east=1", "model": "bworld:fence_side", "y": 90, "shape": [[7, 0, 0, 9, 16, 9]], "collision_shape": [[7, 0, 0, 9, 24, 9]] },
...
]
The side model is the bars on the north side, and y turns it to the others. Parts use the block's textures unless
they set their own, so one pair of models serves every kind of wood. Parts replace model and variants' models.
What sets the states is up to the block's components: the fences' bworld:fence sets them
from what's beside it, every time something next to it changes.
Turning Textures
A model turned by a variant's or part's x or y takes its textures with it, so the planks on a turned stair's step
run another way than on the block next to it. With "uvlock": true, like Minecraft's, each face's texture stays where
it would be on an unturned block instead:
"variants": {
"facing=1": { "y": 90, "uvlock": true }
}
A face that shows part of its texture, with uv, gets the part turned around the texture's middle, which for a face
covering part of the block is the part at its new place.
Item Models
item_model draws a block's item with another model, filled in with the block's textures, like Minecraft's
fence_inventory. Fences use bworld:fence_inventory, two posts and the bars between them, since a single post
wouldn't look like a fence. It's drawn in slots, in hands and on the ground.
An item that isn't a block's can be drawn with a model too, with model instead of its
flat texture, like Create's wrench. The model fills in its texture variables with its own textures, since there's no
block to give them. The item still needs a texture, which the importer takes from the model's particle.
Display Transforms
An item drawn with a model is placed like a block's item unless its model says otherwise: turned to show its top and two
sides in slots, held up like a block, and small on the ground. A model's display places it its own way, in Minecraft's
format, so a wrench can lie at an angle in its slot and be held like a tool:
"display": {
"gui": { "rotation": [28, -163, 43], "translation": [0.5, 0, 0], "scale": [1.1, 1.1, 1.1] },
"firstperson_righthand": { "rotation": [-4.5, 100.25, 10], "translation": [1, 4, 1] }
}
| Place | Where the item is |
|---|---|
gui |
In a slot, the 16 pixels of the item's model across the slot. |
firstperson_righthand |
Held, in first person. |
ground |
Dropped, spinning. |
fixed |
Standing on a block with item_display. |
Each is { rotation, translation, scale }, all [x, y, z] and all around the model's middle: translation moves it in
pixels, rotation turns it in degrees around each axis the way Minecraft's does, and scale sizes it. They start from
the same places Minecraft's do, so a transform made for Minecraft, like in Blockbench's Display tab, looks the same
here. A model gets its parent's transform for each place it doesn't set its own. Minecraft's other places, like third
person, aren't used.
Entity Models as Items
An item's model can also be an entity model, a models/<name>.geo.json made in
Blockbench, drawn in the item's own texture laid out for the model's texture_width and texture_height. It stands
in the middle of the block the way Blockbench shows it, 16 pixels to a block with its bottom at 0, and its faces are
shaded like a block model's. Its pose is the one in the file, bones aren't animated.
Its display transforms are the geometry's item_display_transforms, which Blockbench's Display tab writes for the
"Bedrock Block" format. Only rotation, translation and scale of the places above are used: rotation_pivot,
scale_pivot and fit_to_frame aren't.
Lighting
Faces flat against the block's edge get smooth lighting and ambient occlusion like a full block's. Anything inside the block is lit evenly with the light of the block's own space.