食物注册

Estimated reading time: 2 minutes

用于向原版 setup.foodstuff 添加新的食材、菜品、饮品或可种植物。

使用入口

maplebirch.tool.patch.addFoodstuff(key, config);

key 是食物的唯一标识,建议带模组名前缀,避免和原版或其他模组冲突。

最小示例

maplebirch.tool.patch.addFoodstuff("my_mod_berry", {
  name: "strange berry",
  singular: "strange berry",
  plural: "strange berries",
  category: "fruit",
  icon: "my-mod-berry.png",
  shop: {
    sell_price: 80,
  },
});

常用字段

字段说明默认值
index原版食物索引,不填时自动生成自动
name显示名称由 key 转换
singular单数名称name
plural复数名称name + "s"
icon图标文件名${key}.png
category分类,如 fruitingredientdishingredient
kitchen_item_type_icon厨房分类图标recipe-ingredient.png
prop_folderprop 图片目录ingredient
shop.sell_price售价0
shop.available_in可购买商店,如 ["supermarket"]-
recipe菜谱配置-
food.tags食物标签,如 vegandrinksweet-
tending种植配置-

菜品示例

maplebirch.tool.patch.addFoodstuff("my_mod_soup", {
  name: "herbal soup",
  singular: "serving of herbal soup",
  plural: "servings of herbal soup",
  category: "dish",
  kitchen_item_type_icon: "recipe-food.png",
  prop_folder: "food",
  shop: {
    sell_price: 500,
  },
  recipe: {
    recipe_name: "herbal soup",
    difficulty: 1,
    cook_minutes: 20,
    servings: 1,
    ingredients: ["wild_carrot", "salt"],
    tags: [],
  },
  food: {
    tags: ["vegan"],
  },
});

boot.json

对象映射写法,推荐用于一次注册多个条目

{
  "framework": {
    "foodstuff": {
      "my_mod_berry": {
        "name": "strange berry",
        "category": "fruit",
        "shop": {
          "sell_price": 80
        }
      },
      "my_mod_soup": {
        "name": "herbal soup",
        "category": "dish",
        "kitchen_item_type_icon": "recipe-food.png",
        "prop_folder": "food",
        "shop": {
          "sell_price": 500
        },
        "recipe": {
          "recipe_name": "herbal soup",
          "difficulty": 1,
          "cook_minutes": 20,
          "servings": 1,
          "ingredients": ["wild_carrot", "salt"],
          "tags": []
        }
      }
    }
  }
}

也可以引用 .json.yaml.yml 文件:

{
  "framework": {
    "foodstuff": "data/foodstuff.yaml"
  }
}

数组写法也支持,但每一项必须带 key

- key: my_mod_berry
  name: strange berry
  category: fruit
  shop:
    sell_price: 80
- key: my_mod_soup
  name: herbal soup
  category: dish
  kitchen_item_type_icon: recipe-food.png
  prop_folder: food
  shop:
    sell_price: 500
  recipe:
    recipe_name: herbal soup
    difficulty: 1
    cook_minutes: 20
    servings: 1
    ingredients:
      - wild_carrot
      - salt
    tags: []