Hand crank and shafts

This commit is contained in:
2026-10-15 11:45:12 -03:00
parent cedc7725b5
commit a0596ed0ef
27 changed files with 1008 additions and 36 deletions
+6 -3
View File
@@ -101,7 +101,9 @@ export function setup(ctx: SharedContext) {
Here `block` is `{ id, x, y, z }`, without tile data, which clients never have. `ctx.world` in a shared script has
`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.
[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.
### Neighbors
@@ -116,8 +118,9 @@ a slab's sides and plants aren't.
### Placing
`state_for_placement` picks the states a block is placed with, like Minecraft's `getStateForPlacement`. `placement` is
`{ x, y, z, face, hit, facing, sneaking }`: where it's going, the face of the block that was clicked, where on that
block the click was (from 0 to 1 on each axis), the way the player looks along the ground, and whether they're
`{ x, y, z, face, hit, facing, looking, sneaking }`: where it's going, the face of the block that was clicked, where on
that block the click was (from 0 to 1 on each axis), the way the player looks along the ground, the face of the six they
look most toward, `"top"` or `"bottom"` too, like `getNearestLookingDirection`, and whether they're
[sneaking](../entities/players.md#sneaking), for blocks that sneaking places the other way round. It returns states by
name, and the rest keep their defaults, except that a 2 bit `facing` already faces the player. It runs before the server
checks that no one is in the way, so that's checked against the shape the block will really have. A trapdoor clicked
+3 -1
View File
@@ -22,7 +22,9 @@ ctx.components.register_block("copper_tools:counter", {
});
```
Outside a handler, `ctx.world.get_block_data<T>(x, y, z)` reads it.
Outside a handler, `ctx.world.get_block_data<T>(x, y, z)` reads it. To change another block's data, like a shaft passing
its speed to the next one, `ctx.world.get_block_ref(x, y, z)` gives that block the way its own handlers get it, like
Minecraft's `getBlockEntity`, or `undefined` for air.
- Tile data is saved with the world, and goes away when the block is broken or replaced.
- It's **never sent to clients**. To show it to a player, give it [client data](#client-data), open a