Change how ticking works a little

This commit is contained in:
2026-10-10 20:11:03 -03:00
parent f4cf1d8fa8
commit be05f70fb5
6 changed files with 96 additions and 15 deletions
+5 -3
View File
@@ -67,7 +67,7 @@ component.
| `on_interact(block, params, player)` | A player right clicks it. | `true` if it did something |
| `on_tick(block, params, dt)` | Every tick, 20 times a second, near a player. | |
| `on_second(block, params, dt)` | Every second, near a player. | |
| `on_new_day(block, params, day)` | Every morning at 06:00, anywhere in the world. | |
| `on_new_day(block, params, day)` | Every morning at 06:00. See [Ticking](#ticking) for where. | |
`block` is `{ id, x, y, z, biome, season, data }`, where `data` is the block's [tile data](tiledata.md) and `biome` and
`season` are its column's (see [Seasons](../worldgen/biomes.md#seasons)). `params` is what the block's JSON lists for
@@ -161,8 +161,10 @@ clients guess that the click places the held block and show it for a moment befo
ticks from the start sets `block.data` in `on_create`, like `copper_tools:oxidizes` above.
`on_new_day` runs for every block with tile data in the whole world, near a player or not, so crops keep growing while
nobody's around. When time jumps forward past several mornings, like with `/time add`, each of them runs, up to the
last 64.
nobody's around. Blocks without tile data, like the cacti world generation makes, run it too, but only within 6 chunks
of a player, like the blocks Minecraft random ticks. Blocks one of them places that morning, like a cactus growing a
block taller, wait for the next one. When time jumps forward past several mornings, like with `/time add`, each of them
runs, up to the last 64.
The server runs a fixed 20 ticks a second. When a tick takes too long, up to ten of the next ones run back to back to
catch up. If it's further behind than that, it skips the rest and logs a warning. `/tps` shows how it's keeping up.
+2 -1
View File
@@ -27,7 +27,8 @@ Outside a handler, `ctx.world.get_block_data<T>(x, y, z)` reads it.
- 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, open a [menu](../inventories/menus.md), or change a block
state that the block's `variants` show.
- Only blocks with tile data run `on_tick`, `on_second` and `on_new_day`.
- Only blocks with tile data run `on_tick` and `on_second`. `on_new_day` runs for blocks without it too, but only near
players, see [Ticking](components.md#ticking).
## Blocks With Containers