Files
bworld/docs/modding/blocks/crops.md
T
2026-11-03 17:17:37 -03:00

6.0 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. A crop with seasons dies the first morning that's in another season, turning into a bworld:dead_bush, so a summer crop has to be harvested before autumn comes. The season is its biome's, so a crop that only grows in summer is always out of season in a snowy biome.

A Basic Crop

blocks/cabbages.json, with one texture per stage through variants:

{
	"format_version": 1,
	"block": {
		"id": "bworld:cabbages",
		"model": "cubi:cross",
		"textures": { "cross": "bworld:cabbages_stage0" },
		"variants": {
			"age=1": { "textures": { "cross": "bworld:cabbages_stage1" } },
			"age=2": { "textures": { "cross": "bworld:cabbages_stage2" } }
		},
		"render_layer": "cutout",
		"collision": false,
		"mining": { "toughness": 0 },
		"loot_table": "bworld: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": "bworld:cabbage_seeds",
		"texture": "bworld:cabbage_seeds",
		"places": "bworld: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": "bworld:cabbage",
						"conditions": [{ "condition": "block_state", "states": { "age": 7 } }]
					},
					{
						"item": "bworld:cabbage_seeds",
						"conditions": [
							{ "condition": "inverted", "term": { "condition": "block_state", "states": { "age": 7 } } }
						]
					}
				]
			},
			{
				"conditions": [{ "condition": "block_state", "states": { "age": 7 } }],
				"entries": [
					{
						"item": "bworld: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.
seasons The seasons it grows in, like ["spring", "summer"]. A morning in any other season turns it into a dead bush. Every season when not set.
ripe The block it turns into the morning it's fully grown, like bworld:pumpkin. Its stages spread over the days before, the last one the day before it ripens.

Harvesting By Hand

Tomatoes are picked instead of broken:

"bworld:crop": {
	"days": 11,
	"stages": 8,
	"regrow_days": 4,
	"harvest": "bworld:harvest/tomatoes"
}

with loot_tables/harvest/tomatoes.json giving 1 or 2 tomatoes:

{
	"format_version": 1,
	"loot_table": {
		"pools": [{ "entries": [{ "item": "bworld: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_block", "bworld:hoed_dirt"],
"components": {
	"bworld:crop": {
		"days": 6,
		"stages": 4,
		"water": "always",
		"upper": { "block": "bworld: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": "bworld: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.