Files
bworld/docs/modding/resources/models.md
T
2026-09-29 23:29:14 -03:00

5.2 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 engine:cube unless they set model. For entity models, see Entities.

Built-In Models

Model Texture variables Shape
engine:cube one texture, { top, bottom, side } or { front, side } A full block.
engine:cross cross Two crossed planes, like flowers and saplings.
engine: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.

Texture Variables

Models name their textures with variables, like #side, and blocks fill them in with textures:

{
	"id": "bworld:sapling",
	"model": "engine:cross",
	"textures": { "cross": "bworld:sapling" }
}

For engine: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: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.
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 -45, -22.5, 0, 22.5 or 45 degrees. 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.

Faces are only drawn from the front, so a flat plane that should be seen from both sides needs a face each way.

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.