Add a bunch of crops and farmer's delight crops

This commit is contained in:
2026-09-26 21:35:17 -03:00
parent 8d9c85d379
commit 7e5bcaa239
77 changed files with 980 additions and 81 deletions
+57 -1
View File
@@ -26,7 +26,7 @@ bworld's modding takes from three places:
- [Mod layout](#mod-layout)
- [manifest.json](#manifestjson)
- [Identifiers](#identifiers)
- Data: [Textures](#textures), [Blocks](#blocks), [Block models](#block-models), [Items](#items),
- Data: [Textures](#textures), [Blocks](#blocks), [Block models](#block-models), [Crops](#crops), [Items](#items),
[Recipes](#recipes), [Overrides](#overrides)
- Game API: [Common scripts](#common-scripts), [Server scripts](#server-scripts), [Client scripts](#client-scripts),
[GUIs](#guis), [Mod channels](#mod-channels), [World generation](#world-generation)
@@ -250,6 +250,7 @@ program**, so the server and each client can number blocks differently. Saves an
| `item` | `true` | `register_block_item` | Also register an item that places this block, with the same id. |
| `interactive` | `false` | `interactive` | Right clicking it does something (opens a screen), so clients don't guess it places a block. |
| `replaceable` | `false` | new | Placing a block into it replaces it, like water. |
| `place_in` | see meaning | `place_in` | Block ids it can be placed into, replacing them, like `["bworld:water"]` for rice. Air and `replaceable` blocks when not set. |
| `place_on` | anywhere | `place_on` | Block ids it can stand on, like `["bworld:hoed_dirt"]` for crops. Players can't place it anywhere else, and it breaks (with its drops) when the block under it becomes something else, like Minecraft's `canSurvive`. |
| `states` | none | `states` | Up to 16 bits of named state, like `hoed_dirt` has now. |
| `components` | none | `components` | Custom components with parameters, handled by server scripts. |
@@ -338,6 +339,60 @@ texture per face. `models/slab.json`:
Faces flat against the block's edge get smooth lighting and ambient occlusion like a full block's. Anything inside the
block is lit evenly with the block's own light.
## Crops
Like a Fabric `CropBlock`, a crop is a block with an `age` state and a seeds item that places it, so adding one is only
data. The base game's `bworld:crop` component (in `mods/bworld/scripts/server.ts`) does the growing, with Stardew
Valley's clock: every morning at 06:00 a crop whose farmland was watered the day before grows a day, and it shows the
stage for how far along it is. `mods/farmersdelight` adds its cabbages, onions, tomatoes and rice this way.
`blocks/cabbages.json`, with its `variants` giving one texture per age (see [Block models](#block-models)):
```json
{
"format_version": 1,
"block": {
"id": "farmersdelight:cabbages",
"model": "engine:cross",
"render_layer": "cutout",
"collision": false,
"mining": { "toughness": 0 },
"item": false,
"place_on": ["bworld:hoed_dirt"],
"states": [{ "name": "age", "bits": 3, "default": 0 }],
"components": {
"bworld:crop": {
"days": 12,
"stages": 8,
"fertilizer": "bworld:bone_meal",
"drops": {
"young": "farmersdelight:cabbage_seeds",
"mature": "farmersdelight:cabbage",
"bonus": "farmersdelight:cabbage_seeds"
}
}
}
}
}
```
and `items/cabbage_seeds.json` with `"places": "farmersdelight:cabbages"`.
| 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` | Like a crop's loot table: `young` (not grown yet), `mature` (grown), and `bonus`, 0 to 3 more of an item when grown, like wheat's extra seeds. `young` and `mature` can be one id or a list. |
| `fertilizer` | An item that grows it a day right away, like bone meal. |
| `regrow_days`, `harvest` | Picked by right clicking once grown, dropping `harvest.item` (`count` is `[min, max]`), then grown again after `regrow_days`, like tomatoes. |
| `water` | `"farmland"` (the default): needs watered farmland under it. `"always"`: grows every morning, like rice in water. |
| `upper` | `{ block, stages, supporting_age }`: its last stages grow a second block on top, like rice's panicles. The top block uses the `bworld:crop_top` component with `{ stages, drops }`; breaking it harvests the whole plant. |
| `leaves` | What the spot becomes after it's broken, like water where rice was. |
Players place blocks into the block they click when it's `replaceable`, like Minecraft, so rice (with
`"place_in": ["bworld:water"]`) is planted by clicking water. Food that places a block, like potatoes, is planted when
clicked on somewhere it can go and eaten otherwise.
## Items
`items/copper_pickaxe.json`:
@@ -663,6 +718,7 @@ or place, the server tells that player's client to undo what it already showed.
interface ServerWorld {
get_block(x: number, y: number, z: number): string | undefined; // undefined when the chunk isn't loaded
set_block(x: number, y: number, z: number, id: string): boolean; // runs on_break / on_create, synced to everyone
break_block(x: number, y: number, z: number): boolean; // like breaking it by hand: on_break, then its drops
get_state(x: number, y: number, z: number, name: string): number | undefined;
set_state(x: number, y: number, z: number, name: string, value: number): boolean;
get_block_data<T>(x: number, y: number, z: number): T | undefined;