Files
bworld/docs/modding/items/food.md
T
2026-10-31 17:50:53 -03:00

3.5 KiB
Raw Blame History

Food

An item with a food property can be eaten. Players eat by right clicking while holding it, when they're hungry.

{
	"format_version": 1,
	"item": {
		"id": "farmersdelight:cooked_rice",
		"texture": "farmersdelight:cooked_rice",
		"max_stack": 16,
		"food": { "nutrition": 6, "saturation_modifier": 0.4, "returns": "bworld:bowl" }
	}
}
Field Default Meaning
nutrition required Hunger points it restores, out of 20. A whole number.
saturation_modifier required Like Minecraft's: the saturation it gives is nutrition × modifier × 2. Bread's is 0.6.
always_edible false Can be eaten even when not hungry.
returns none An item left in the hand after eating, like a bowl after soup.

Food that places a block, like potatoes with places, is planted when clicked somewhere it can go and eaten otherwise.

Juice

Items that can be juiced, like fruit, have the base game's bworld:juiceable component:

"components": {
	"bworld:juiceable": { "juice": 100, "color": "#c42d39" }
}
Param What it does
juice How much juice one makes, in mB. A bottle is 250.
color The juice's color, like "#c42d39".

All juice is one fluid, bworld:juice, and the item it's made from is in its data: { "id": "bworld:juice", "data": { "item": "bworld:strawberry" } }. The base game's rules name it after that item, "Strawberry Juice", in the color its component says, so juice from another mod's item needs nothing but the component. Juices from different items are different fluids, so they never share a bottle or a tank. Glass bottles (bworld:glass_bottle, 250 mB) and buckets (bworld:bucket, 1000 mB) hold it. The base game makes a juicing recipe for every item with the component, which is what the juicer goes by.

Juice ferments into wine, bworld:wine, which keeps the item in its data and is named and colored after it the same way, "Strawberry Wine". The base game makes a fermentable recipe for every juice.

Juice sells for 1.2 times the items it took to make, rounded up, so it's always worth juicing something. A bottle of juice from an item worth 30 that makes 200 mB took 1.25 of them, and sells for 45. Juice from an item without a base_sell_value can't be sold.

Hunger and Health

Hunger and health work like Minecraft's:

  • Sprinting, swimming, jumping, breaking blocks, taking damage and healing add exhaustion. Every 4 exhaustion costs a point of saturation, or of hunger once saturation is gone.
  • A full stomach heals: quickly while there's saturation, slowly with at least 18 hunger.
  • At 0 hunger, players lose health every 4 seconds, down to half a heart.

Server scripts can feed players directly, and read and change their hunger. See Players.

player.feed(4, 0.3); // like eating 4 nutrition with a 0.3 modifier
player.add_exhaustion(8); // two points of saturation or hunger