Cog wheels
This commit is contained in:
@@ -93,11 +93,11 @@ export function setup(ctx: SharedContext) {
|
||||
}
|
||||
```
|
||||
|
||||
| Rule | Called when | Returns |
|
||||
| --------------------------------------------- | ---------------------------------------------------------------------- | -------------------------- |
|
||||
| `state_for_placement(placement, params)` | A player is about to place it. | States to place it with |
|
||||
| `on_neighbor_change(block, params, neighbor)` | A block on one of its 6 sides is placed, broken or changes its states. | |
|
||||
| `on_interact(block, params, interaction)` | A player right clicks it. | `true` if it did something |
|
||||
| Rule | Called when | Returns |
|
||||
| --------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------- |
|
||||
| `state_for_placement(placement, params)` | A player is about to place it. | States to place it with, or `false` when it can't go there |
|
||||
| `on_neighbor_change(block, params, neighbor)` | A block on one of its 6 sides is placed, broken or changes its states. | |
|
||||
| `on_interact(block, params, interaction)` | A player right clicks it. | `true` if it did something |
|
||||
|
||||
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
|
||||
@@ -122,9 +122,11 @@ a slab's sides and plants aren't.
|
||||
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
|
||||
onto the upper half of a block's side hangs in the top half:
|
||||
name, and the rest keep their defaults, except that a 2 bit `facing` already faces the player. Returning `false` means
|
||||
it can't go there at all, like a large cogwheel right beside another cogwheel, and nothing is placed, like
|
||||
`getStateForPlacement` returning `null`. 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 onto the upper half of a block's side hangs in the top
|
||||
half:
|
||||
|
||||
```ts
|
||||
state_for_placement(placement): Record<string, number> {
|
||||
|
||||
Reference in New Issue
Block a user