Proper season and time conditions for fishing

This commit is contained in:
2026-10-08 15:49:46 -03:00
parent 9c5a15542a
commit aa0d2f73d0
11 changed files with 86 additions and 76 deletions
+2
View File
@@ -32,6 +32,8 @@ For work every tick, subscribe to the `tick` event. For work on a block, use a
`ctx.world.day` is the number of days since the world started, 0 on the first day, going up at 06:00. Every morning at
06:00, blocks' `on_new_day` runs, then the `new_day` event fires. That's the clock crops grow on.
`ctx.world.hour` is the time on a 24 hour clock, in hours: `14.5` is 14:30.
`ctx.world.set_time(ticks)` changes the time for everyone. Moving it forward past mornings runs each of them, up to the
last 64. Moving it back doesn't repeat mornings.
+24 -1
View File
@@ -126,11 +126,34 @@ does nothing unless they hold.
| [Blocks](../blocks/index.md) | `"loot_table"` in the block's json, rolled when it breaks, with its states and the tool. `"drops"` is the shorthand for one of an item. |
| [Mobs](../entities/index.md) | `"loot_table"` in the entity's json, rolled when it dies. `killed_by_player` holds when a player killed it. |
| [Crops](../blocks/crops.md) | Their block's `loot_table`, with `block_state` on `age` for grown or not. `harvest` is a table for picking. |
| Fishing | The fishing rod's `loot_table`, `bworld:gameplay/fishing`. |
| Fishing | The fishing rod's `loot_table`, `bworld:gameplay/fishing`, rolled when it's reeled in. See [Fishing](#fishing). |
| Scripts | `ctx.loot.roll` and `ctx.loot.fill`, for anything else, like chests in structures. |
`check-mods` checks that every item, tag and table a table names exists, and that the tables blocks and mobs name do.
## Fishing
The base game adds two conditions for picking fish by where and when they're reeled in:
| `condition` | Fields | Holds when |
| --------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------- |
| `bworld:season` | `seasons` | The [season](../worldgen/biomes.md#seasons) where it happens is one of `seasons`, like `["summer", "autumn"]`. |
| `bworld:time` | `from`, `to` | The hour on a 24 hour clock is from `from` up to `to`, like `6.5` for 06:30. When `from` is past `to` it wraps around midnight. |
A fish without a `bworld:season` is caught in every season, and one without `bworld:time` all day:
```json
{
"item": "my_mod:catfish",
"conditions": [
{ "condition": "bworld:season", "seasons": ["summer", "autumn"] },
{ "condition": "bworld:time", "from": 20, "to": 4 }
]
}
```
When every fish can be ruled out, nothing is caught, so keep one without conditions.
## From a Script
Server scripts roll tables, fill containers, and add conditions, functions and changes of their own: