5.4 KiB
Crops
A crop is a block with an age state, the base game's bworld:crop component, and a seeds item that
places it. Adding one takes no code.
Crops grow on Stardew Valley's clock with Minecraft's rules: every morning at 06:00, a crop whose farmland was watered
the day before grows a day, then all farmland dries out. The crop shows the stage for how far along it is.
mods/farmersdelight adds its cabbages, onions, tomatoes and rice this way.
A Basic Crop
blocks/cabbages.json, with one texture per stage through variants:
{
"format_version": 1,
"block": {
"id": "farmersdelight:cabbages",
"model": "engine:cross",
"textures": { "cross": "farmersdelight:cabbages_stage0" },
"variants": {
"age=1": { "textures": { "cross": "farmersdelight:cabbages_stage1" } },
"age=2": { "textures": { "cross": "farmersdelight:cabbages_stage2" } }
},
"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 }],
"components": {
"bworld:crop": {
"days": 12,
"stages": 8,
"fertilizer": "bworld:bone_meal"
}
}
}
}
"item": false because players plant the seeds, not the crop. items/cabbage_seeds.json:
{
"format_version": 1,
"item": {
"id": "farmersdelight:cabbage_seeds",
"texture": "farmersdelight:cabbage_seeds",
"places": "farmersdelight:cabbages"
}
}
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, 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:
{
"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. |
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 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
Tomatoes are picked instead of broken:
"bworld:crop": {
"days": 11,
"stages": 8,
"regrow_days": 4,
"harvest": "farmersdelight:harvest/tomatoes"
}
with loot_tables/harvest/tomatoes.json giving 1 or 2 tomatoes:
{
"format_version": 1,
"loot_table": {
"pools": [{ "entries": [{ "item": "farmersdelight:tomato", "count": { "min": 1, "max": 2 } }] }]
}
}
Two Block Crops
Rice grows in water and, once it's tall enough, grows panicles on top. The crop stays at supporting_age while the top
block goes through its own stages:
"place_in": ["bworld:water"],
"place_on": ["bworld:dirt", "bworld:grass", "bworld:hoed_dirt"],
"components": {
"bworld:crop": {
"days": 6,
"stages": 4,
"water": "always",
"upper": { "block": "farmersdelight:rice_panicles", "stages": 4, "supporting_age": 4 },
"leaves": "bworld:water"
}
}
The top block uses bworld:crop_top with its own stages, and its own loot table. Breaking either half harvests the
whole plant:
"loot_table": "farmersdelight:blocks/rice_panicles",
"components": {
"bworld:crop_top": { "stages": 4 }
}
Since water is replaceable and rice has place_in, players plant rice by clicking the water itself.