This commit is contained in:
2026-10-28 22:26:42 -03:00
parent b8cccb86ff
commit 5d64b801a3
14 changed files with 480 additions and 12 deletions
+18
View File
@@ -72,12 +72,30 @@ component.
| `on_neighbor_change(block, params, neighbor)` | A block on one of its 6 sides is placed, broken or changes its states. See [Changes](#changes). | |
| `on_state_change(block, params, before)` | Its own states change without it being replaced, by `set_state` or a rule. See [Changes](#changes). | |
| `on_scheduled_tick(block, params)` | A tick it asked for comes. See [Scheduled Ticks](#scheduled-ticks). | |
| `on_entity_stand(block, params, entity)` | An entity standing on it moves, every tick it does. See [Entities on It](#entities-on-it). | |
`block` is `{ id, x, y, z, biome, season, data, get_client_data, set_client_data, set_ticking }`, where `data` is the
block's [tile data](tiledata.md) and the client data functions its [part clients see](tiledata.md#client-data), `biome`
and `season` are its column's (see [Seasons](../worldgen/biomes.md#seasons)) and `set_ticking` turns its
[ticking](#ticking) off and on. `params` is what the block's JSON lists for this component, and `dt` is in seconds.
### Entities on It
`on_entity_stand` runs every tick an entity moves while it stands on the block, like Minecraft's
`updateEntityAfterFallOn`, with an [`EntityRef`](../entities/index.md) to it. Items lying still move every tick too, so
it runs for them while they lie there. The block is the one under the entity's feet, or the one its feet are in when
that one's floor is lower than a whole block, like a basin's. Create's basin takes in the items dropped into it this
way, without ticking or looking for them:
```ts
ctx.components.register_block("create:basin", {
on_entity_stand(block, _params, entity) {
const item = entity.get_item();
if (item) entity.set_item(insert(block, item));
},
});
```
### Changes
`on_neighbor_change` is the server's side of the [rule](#neighbors) with the same name, like NeoForge's