ctx.blocks.solid(id) api

This commit is contained in:
2026-10-20 14:22:11 -03:00
parent 987e7a0f9a
commit 0bc66c21b9
11 changed files with 115 additions and 5 deletions
+1 -1
View File
@@ -151,7 +151,7 @@ Here `block` is `{ id, x, y, z }`, without tile data, which clients never have.
`get_block`, `get_state`, `set_state`, `is_face_sturdy`, `biome_at` and `season_at` (see
[Seasons](../worldgen/biomes.md#seasons)), and only works inside rules. `ctx.blocks.components(id)` gives any block's
components and their params, like on the server, for rules that look at what's around them, like a shaft lining up with
the axle of the block it's placed against.
the axle of the block it's placed against, and `ctx.blocks.solid(id)` whether it's [solid](index.md#solid-blocks).
### Neighbors
+8
View File
@@ -75,6 +75,14 @@ there will be holes in the world behind them.
A block's definition goes to every player, since clients need it to draw the block, time breaking and collide with it.
It can't hold functions.
### Solid Blocks
A block is solid when it's drawn in the `solid` layer and entities bump into a whole block in every state: stone,
planks, logs and furnaces are, glass, leaves, slabs, chests and fences aren't. Every variant counts, even one that no
state shows, and blocks made of `parts` never are. Scripts on every side ask with `ctx.blocks.solid(id)`, which is
`false` for air and throws for a block that doesn't exist. It's worked out once per block, so it's cheap enough to ask
for every block a walk goes through, unlike `ctx.world.is_face_sturdy`, which looks at the block at a position.
## Mining
Breaking takes `mining.toughness` seconds by hand. A tool whose type matches `mining.tool` breaks it `tool.speed` times