User Tools

Site Tools


items:item_components:food

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
items:item_components:food [2024/04/19 13:27] – removed - external edit (Unknown date) 127.0.0.1items:item_components:food [2024/04/19 13:27] (current) – ↷ Links adapted because of a move operation errorcraft
Line 1: Line 1:
 +====== minecraft:food ======
 +The ''minecraft:food'' item component adds nutrition points and saturation to its user after consuming the item.
 +Its values may be overridden for a specific item stack by using the [[mc>Item_format/1.20.5#food|minecraft:food]] item stack component.
 +Note that not all vanilla fields are still used in the item stack component.
 +This item component is usually combined with [[items:item_components:use_duration|minecraft:use_duration]], [[items:item_components:use_animation|minecraft:use_animation]] and [[items:item_components:consumable|minecraft:consumable]].
  
 +
 +===== Fields =====
 +^  Name  ^  Description  ^  Type  ^  Default Value  ^
 +| ''nutrition'' | How many nutrition points to add after consuming. | A non-negative integer |
 +| ''saturation'' | How much saturation to add after consuming. | A float | |
 +| ''always_edible'' | Whether the food item is edible, regardless if a player's hunger bar is full or not. | An optional boolean | ''false'' |
 +| ''effects'' | The [[#possible effect|possible effects]] to add after consuming. | An optional list of [[#possible effect|possible effects]] | ''[]'' |
 +
 +
 +===== Example =====
 +<code javascript>
 +{
 +  "nutrition": 2,
 +  "saturation": 1.2,
 +  "effects": [
 +    {
 +      "effect": {
 +        "id": "minecraft:poison",
 +        "duration": 100,
 +        "show_icon": true
 +      },
 +      "probability": 0.6
 +    }
 +  ]
 +}
 +</code>
 +
 +
 +===== Possible Effect =====
 +An effect that may or may not be applied after consuming.
 +
 +
 +==== Fields ====
 +^  Name  ^  Description  ^  Type  ^  Default Value  ^
 +| ''effect'' | An [[mc>Effect|effect instance]]. | An [[mc>Effect|effect instance]] | |
 +| ''probability'' | The probability of applying the effect. | A float ranging from ''0.0'' to ''1.0'' inclusive | ''1.0'' |
 +
 +
 +==== Example ====
 +<code javascript>
 +{
 +  "effect": {
 +    "id": "minecraft:poison",
 +    "duration": 100,
 +    "show_icon": true
 +  },
 +  "probability": 0.6
 +}
 +</code>