Some more kinetic blocks
This commit is contained in:
@@ -169,9 +169,10 @@ 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, 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
|
||||
`{ x, y, z, item, face, hit, facing, looking, sneaking }`: where it's going, the item placing it (the block's own, or
|
||||
another whose `places` is this block, like Minecraft's `getItemInHand`), 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. Returning `false` means
|
||||
it can't go there at all, like a large cogwheel right beside another cogwheel, and nothing is placed, like
|
||||
|
||||
@@ -34,6 +34,15 @@ everyone who can see the block. Unlike `set_block`, it doesn't run `on_break` or
|
||||
tile data. It runs the block's [`on_state_change`](components.md#changes) instead, and tells the blocks beside it,
|
||||
unless it's given `{ update_neighbors: false }`.
|
||||
|
||||
`set_block` puts a block there with its states at their defaults, or with the ones it's given, like Minecraft's
|
||||
`setBlock` with a block state. Turning one block into another that keeps its direction looks like this, and `on_create`
|
||||
already sees the new block turned the right way:
|
||||
|
||||
```ts
|
||||
const axis = ctx.world.get_state(x, y, z, "axis")!;
|
||||
ctx.world.set_block(x, y, z, "create:andesite_encased_shaft", { axis });
|
||||
```
|
||||
|
||||
## Variants
|
||||
|
||||
`variants` gives a block a different `model`, `textures` or rotation depending on its states. `blocks/wheat.json` shows
|
||||
|
||||
@@ -82,12 +82,15 @@ The torch gives power out of every side but the block it's on, and strongly into
|
||||
| Param | Default | Meaning |
|
||||
| ---------- | ---------- | ------------------------------------------------------------- |
|
||||
| `state` | | A 1 bit state it keeps whether it's powered in: 1 while it is |
|
||||
| `power` | | A 4 bit state it keeps how much power comes in in, 0 to 15 |
|
||||
| `facing` | | Which way it points, see [Sides](#sides) |
|
||||
| `in` | every side | The sides it takes power from |
|
||||
| `connects` | `in` | The sides wire joins |
|
||||
|
||||
The component works out its input when the block is placed and whenever a block beside it changes, and sets the state,
|
||||
which does nothing when it's already right. It's on or off: a state for how much power comes in isn't supported yet.
|
||||
which does nothing when it's already right. A block that does more the more power it gets, like Create's adjustable
|
||||
chain gearshift, also names a 4 bit `power` state, which gets the most power coming into any of its sides. It's set
|
||||
before `state`, so `on_state_change` sees both up to date when `state` changes.
|
||||
|
||||
A trapdoor lists it with a `powered` state:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user