Better block models !

This commit is contained in:
2026-10-03 15:57:47 -03:00
parent ecc0295f6d
commit 24fe7cdede
23 changed files with 678 additions and 122 deletions
+2 -1
View File
@@ -52,6 +52,7 @@ there will be holes in the world behind them.
| Field | Default | Meaning |
| ---------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `collision` | `true` | Whether entities bump into it. Plants and water set `false`. |
| `shape` | its model | The boxes players point at and entities bump into, in pixels. See [Shapes](../resources/models.md#shapes). |
| `mining.toughness` | unbreakable | Seconds to break by hand. Without `mining`, a block can't be broken. |
| `mining.tool` | none | The [tool type](../items/tools.md) that breaks it faster, like `pickaxe`, `axe` or `shovel`. |
| `mining.requires_tool` | `false` | Only drops when broken with `mining.tool`. |
@@ -86,7 +87,7 @@ It's only placed when:
- the spot is one it can go into: air or a `replaceable` block, or one of `place_in`,
- the block under the spot is one of `place_on`, when the block has `place_on`,
- and, for blocks with collision, no player or mob is in the way.
- and, for blocks with collision, no player or mob is in the way of its [shape](../resources/models.md#shapes).
A block with `place_on` also pops off (dropping what it drops) when the block under it becomes something else, like a
crop when its farmland is dug up.
+4 -4
View File
@@ -58,10 +58,10 @@ a texture per growth stage:
- A key is a condition on the block's states: `"age=3"`, or `"age=3,facing=1"` when all of them have to match. `""`
matches always.
- A variant sets any of `model`, `textures` and `y`, a turn around the vertical axis of 0, 90, 180 or 270 degrees,
clockwise seen from above.
- **Each of the three comes from the first matching variant that sets it.** So one variant can turn the block and a
later one change its textures, and both apply.
- A variant sets any of `model`, `textures`, `y`, a turn around the vertical axis of 0, 90, 180 or 270 degrees,
clockwise seen from above, and [`shape`](../resources/models.md#shapes).
- **Each of them comes from the first matching variant that sets it.** So one variant can turn the block and a later one
change its textures, and both apply.
- What no matching variant sets comes from the block itself.
## Facing
+34
View File
@@ -77,6 +77,40 @@ 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.
## 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
`engine:cross` and `engine: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](../blocks/states.md) can set
their own, like a crop that's taller the older it is:
```json
{
"id": "copper_tools:rice",
"model": "engine: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, so a shape can't be taller than a block like Minecraft's fences.
## Lighting
Faces flat against the block's edge get smooth lighting and ambient occlusion like a full block's. Anything inside the