Loot tables

This commit is contained in:
2026-10-08 00:54:45 -03:00
parent 757ee74bc7
commit ec2b53c02a
45 changed files with 1733 additions and 150 deletions
+66 -24
View File
@@ -25,6 +25,7 @@ the day before grows a day, then all farmland dries out. The crop shows the stag
"render_layer": "cutout",
"collision": false,
"mining": { "toughness": 0 },
"loot_table": "farmersdelight:blocks/cabbages",
"item": false,
"place_on": ["bworld:hoed_dirt"],
"states": [{ "name": "age", "bits": 3, "default": 0 }],
@@ -32,12 +33,7 @@ the day before grows a day, then all farmland dries out. The crop shows the stag
"bworld:crop": {
"days": 12,
"stages": 8,
"fertilizer": "bworld:bone_meal",
"drops": {
"young": "farmersdelight:cabbage_seeds",
"mature": "farmersdelight:cabbage",
"bonus": "farmersdelight:cabbage_seeds"
}
"fertilizer": "bworld:bone_meal"
}
}
}
@@ -59,18 +55,56 @@ the day before grows a day, then all farmland dries out. The crop shows the stag
`place_on` keeps it on farmland, and it pops off when the farmland is dug up.
## Drops
What a crop drops is its block's [loot table](../resources/loot_tables.md), with a `block_state` condition on `age` for
grown or not. `loot_tables/blocks/cabbages.json` gives a seed while it grows, and once it's grown at age 7 the cabbage
and 1 to 4 seeds, like Minecraft's wheat:
```json
{
"format_version": 1,
"loot_table": {
"pools": [
{
"entries": [
{
"item": "farmersdelight:cabbage",
"conditions": [{ "condition": "block_state", "states": { "age": 7 } }]
},
{
"item": "farmersdelight:cabbage_seeds",
"conditions": [
{ "condition": "inverted", "term": { "condition": "block_state", "states": { "age": 7 } } }
]
}
]
},
{
"conditions": [{ "condition": "block_state", "states": { "age": 7 } }],
"entries": [
{
"item": "farmersdelight:cabbage_seeds",
"functions": [{ "function": "set_count", "count": { "n": 3, "p": 0.5714 }, "add": true }]
}
]
}
]
}
}
```
## Parameters
| Param | Meaning |
| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `days` | Watered mornings from planting to fully grown. |
| `stages` | How many ages it shows, 0 to `stages - 1`, spread evenly over `days`. The `age` state must fit them. |
| `drops` | What it drops when broken: `young` before it's grown, `mature` once it is, and `bonus`, 1 to 4 of an item when grown (Minecraft's 1 plus 3 tries at 57%, like wheat's seeds). `young` and `mature` can be one id or a list. |
| `fertilizer` | An item that grows it a day right away when used on it, like bone meal. |
| `water` | `"farmland"` (the default) needs watered farmland under it. `"always"` grows every morning. |
| `regrow_days`, `harvest` | Right clicking it once grown picks it, dropping `harvest.item` (`count` is `[min, max]`), and it grows back after `regrow_days`. |
| `upper` | `{ block, stages, supporting_age }`: its last stages grow a second block on top, see below. |
| `leaves` | What the spot becomes when it's broken, like the water rice was planted in. |
| Param | Meaning |
| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `days` | Watered mornings from planting to fully grown. |
| `stages` | How many ages it shows, 0 to `stages - 1`, spread evenly over `days`. The `age` state must fit them. |
| `fertilizer` | An item that grows it a day right away when used on it, like bone meal. |
| `water` | `"farmland"` (the default) needs watered farmland under it. `"always"` grows every morning. |
| `regrow_days`, `harvest` | Right clicking it once grown picks it, dropping what the [loot table](../resources/loot_tables.md) `harvest` gives, and it grows back after `regrow_days`. |
| `upper` | `{ block, stages, supporting_age }`: its last stages grow a second block on top, see below. |
| `leaves` | What the spot becomes when it's broken, like the water rice was planted in. |
## Harvesting By Hand
@@ -81,10 +115,17 @@ Tomatoes are picked instead of broken:
"days": 11,
"stages": 8,
"regrow_days": 4,
"harvest": { "item": "farmersdelight:tomato", "count": [1, 2] },
"drops": {
"young": "farmersdelight:tomato_seeds",
"mature": ["farmersdelight:tomato", "farmersdelight:tomato_seeds"]
"harvest": "farmersdelight:harvest/tomatoes"
}
```
with `loot_tables/harvest/tomatoes.json` giving 1 or 2 tomatoes:
```json
{
"format_version": 1,
"loot_table": {
"pools": [{ "entries": [{ "item": "farmersdelight:tomato", "count": { "min": 1, "max": 2 } }] }]
}
}
```
@@ -103,17 +144,18 @@ block goes through its own `stages`:
"stages": 4,
"water": "always",
"upper": { "block": "farmersdelight:rice_panicles", "stages": 4, "supporting_age": 4 },
"leaves": "bworld:water",
"drops": { "young": "farmersdelight:rice", "mature": "farmersdelight:rice" }
"leaves": "bworld:water"
}
}
```
The top block uses `bworld:crop_top` with its own `stages` and `drops`. Breaking either half harvests the whole plant:
The top block uses `bworld:crop_top` with its own `stages`, and its own loot table. Breaking either half harvests the
whole plant:
```json
"loot_table": "farmersdelight:blocks/rice_panicles",
"components": {
"bworld:crop_top": { "stages": 4, "drops": { "mature": "farmersdelight:rice_panicle" } }
"bworld:crop_top": { "stages": 4 }
}
```
+4 -3
View File
@@ -60,7 +60,8 @@ there will be holes in the world behind them.
| `mining.tool` | none | The [tool type](../items/tools.md) that breaks it faster, like `pickaxe`, `axe` or `shovel`. |
| `mining.requires_tool` | `false` | Only drops when broken with `mining.tool`. |
| `mining.tier` | `0` | With `requires_tool`, the lowest tool tier it drops for. Iron ore is `1`, so a wood pickaxe gets nothing. |
| `drops` | nothing | The item id it drops when broken. |
| `drops` | nothing | The item id it drops when broken, one of it. |
| `loot_table` | none | A [loot table](../resources/loot_tables.md) it drops from when broken instead, with its states and the tool. Not with `drops`. |
| `item` | `true` | Also register an item that places it, with the same id. To give that item more, see [Block Items](../items/index.md#block-items). |
| `interactive` | `false` | Right clicking it does something, like opening a screen, so clients don't guess that it places a block. |
| `replaceable` | `false` | Placing a block into it replaces it, like water. Liquids default to `true`. |
@@ -79,8 +80,8 @@ It can't hold functions.
Breaking takes `mining.toughness` seconds by hand. A tool whose type matches `mining.tool` breaks it `tool.speed` times
faster. The client times breaking itself, and the server checks the result.
When it breaks, the block's components' `on_break` runs and it drops `drops`, unless it has `requires_tool` and the
player's tool is the wrong type or a tier below `mining.tier`.
When it breaks, the block's components' `on_break` runs and it drops `drops` or what its `loot_table` gives, unless it
has `requires_tool` and the player's tool is the wrong type or a tier below `mining.tier`.
## Placement