手冊:實例/附加包/物品/食物

出自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"
    }
  }
}