手册:实例/附加包/物品/食物

来自Minecraft基岩版开发Wiki

旧格式食物[编辑]

这是一个使用1.10格式版本、ID为wiki:food、纹理短名称为wiki.food,食用后给予4点饥饿值与60秒的中毒效果的食物。

行为包文件[编辑]

{
  "format_version": "1.10",
  "minecraft:item": {
    "description": {
      "identifier": "wiki:food"
    },
    
    "components": {
      "minecraft:hand_equipped": false,
      "minecraft:stacked_by_data": true,
      "minecraft:use_duration": 32,
      "minecraft:foil": true,
      "minecraft:food": {
        "nutrition": 4,
        "saturation_modifier": "supernatural",
        "can_always_eat": true,
        "effects": [
          {
            "name": "poison",
            "chance": 1.0,
            "duration": 60,
            "amplifier": 0
          }
        ]
      }
    }
  }
}

资源包文件[编辑]

{
  "format_version": "1.10",
  "minecraft:item": {
    "description": {
      "identifier": "wiki:food",
      "category": "Nature"
    },
    "components": {
      "minecraft:icon": "wiki.food",
      "minecraft:use_animation": "eat",
      "minecraft:render_offsets": "apple"
    }
  }
}

新格式食物[编辑]

这是一个使用1.20.10格式版本、ID为wiki:food、纹理短名称为wiki.food的食物。

{
  "format_version": "1.20.10",
  "minecraft:item": {
    "description": {
      "identifier": "wiki:food" 
    },
    "components": {
      "minecraft:creative_category": {
        "category": "nature",
        "parent": "itemGroup.name.crop"
      },
      "minecraft:icon": {
        "texture": "wiki.food"
      },
      "minecraft:food": {
        "nutrition": 4,
        "saturation_modifier": 0.6
      },
      "minecraft:use_duration": 1.2,
      "minecraft:use_animation": "eat"
    }
  }
}