Add various generic models

This commit is contained in:
2026-10-12 17:56:47 -03:00
parent e5baeab193
commit d4eff11f3e
34 changed files with 786 additions and 251 deletions
+39
View File
@@ -65,6 +65,7 @@ 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](#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 -45, -22.5, 0, 22.5 or 45 degrees. `rescale` stretches it back to the block's width. |
@@ -77,6 +78,44 @@ on every face, since `top` and `bottom` default to `#side`.
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, with its own winning. A parent can have a parent too. `models/brass_gear.json` reuses a
gear's shape with other textures:
```json
{
"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:
```json
{
"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