Make the fishing loot table be generated from the fish items
This commit is contained in:
@@ -166,6 +166,7 @@ watering can uses `bworld:water_source`, or subscribe to the `block_interact` [e
|
||||
|
||||
```ts
|
||||
ctx.items.exists("bworld:carrot"); // true
|
||||
ctx.items.ids(); // every item, in load order
|
||||
ctx.items.max_stack("bworld:wood_pickaxe"); // 1
|
||||
ctx.items.tool("bworld:wood_pickaxe"); // "pickaxe", or undefined for items that aren't tools
|
||||
ctx.items.sell_value("bworld:copper_coin"); // 1, or undefined for items without a base_sell_value
|
||||
|
||||
@@ -11,7 +11,7 @@ Every `.json` in a mod's `loot_tables/` folder is a table, and its id is its pat
|
||||
| File | Loot table id |
|
||||
| ----------------------------------- | ------------------------------ |
|
||||
| `loot_tables/blocks/wheat.json` | `bworld:blocks/wheat` |
|
||||
| `loot_tables/gameplay/fishing.json` | `bworld:gameplay/fishing` |
|
||||
| `loot_tables/chests/ruin.json` | `my_mod:chests/ruin` |
|
||||
| `loot_tables/entities/rotling.json` | `undergarden:entities/rotling` |
|
||||
|
||||
The folders are only for keeping things tidy. By habit, `blocks/` is for blocks, `entities/` for mobs, `gameplay/` for
|
||||
@@ -133,26 +133,33 @@ does nothing unless they hold.
|
||||
|
||||
## 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:
|
||||
The fishing table, `bworld:gameplay/fishing`, isn't a file: the base game builds it from every item with the
|
||||
`bworld:fish` component, so a mod adds a fish by giving its item the component:
|
||||
|
||||
```json
|
||||
{
|
||||
"item": "my_mod:catfish",
|
||||
"conditions": [
|
||||
{ "condition": "bworld:season", "seasons": ["summer", "autumn"] },
|
||||
{ "condition": "bworld:time", "from": 20, "to": 4 }
|
||||
]
|
||||
"components": {
|
||||
"bworld:fish": {
|
||||
"weight": 20,
|
||||
"seasons": ["summer", "autumn"],
|
||||
"time": { "from": 20, "to": 4 }
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
When every fish can be ruled out, nothing is caught, so keep one without conditions.
|
||||
| Field | What |
|
||||
| --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `weight` | How often it's caught against the other fish, 1 when not given. |
|
||||
| `seasons` | The [seasons](../worldgen/biomes.md#seasons) it's caught in where the hook is, every one when not given. |
|
||||
| `time` | The hours it's caught at on a 24 hour clock, from `from` up to `to`, like `6.5` for 06:30. When `from` is past `to` it wraps around midnight. All day when not given. |
|
||||
|
||||
When every fish can be ruled out, nothing is caught, so keep one that's always caught.
|
||||
|
||||
Those become the `bworld:season` and `bworld:time` conditions, which any table can use too:
|
||||
|
||||
| `condition` | Fields | Holds when |
|
||||
| --------------- | ------------ | ----------------------------------------------------------------------------- |
|
||||
| `bworld:season` | `seasons` | The season where it happens is one of `seasons`, like `["summer", "autumn"]`. |
|
||||
| `bworld:time` | `from`, `to` | The hour is from `from` up to `to`, the same as the fish's `time`. |
|
||||
|
||||
## From a Script
|
||||
|
||||
@@ -183,6 +190,7 @@ export function setup(ctx: ServerContext) {
|
||||
| `register_condition(id, fn)` | A condition: `fn(params, context)` says whether it holds. Setup only. |
|
||||
| `register_function(id, fn)` | A function: `fn(item, params, context)` gives the changed item, or `undefined` to take it away. Setup only. |
|
||||
| `modify(table, fn)` | Changes what a table gives each time, or every table's with `"*"`. `fn(items, context, table)` changes the list or returns a new one. Setup only. |
|
||||
| `register_table(id, table)` | A table made by the script instead of a file, `table` being what a file's `"loot_table"` is, like the fishing table. Setup only. |
|
||||
|
||||
`params` is the condition's or function's json. Ids are in the mod's namespace, and a table that uses one nobody
|
||||
registered stops the server from starting, like a missing [component](../blocks/components.md). What a mod's code throws
|
||||
|
||||
Reference in New Issue
Block a user