Skip to content

Example Datapack

Jeremy edited this page Oct 3, 2026 · 4 revisions

This page reviews an example datapack that adds a new food group, adds it to the default diet suite, and assigns a food to it. For general information on creating and activating datapacks, see Using Datapacks.

Getting Started

First, download the example datapack.

Unzip the file and there will be the following folder structure:

data/
├── diet/
│   └── tags/
│       └── items/
│           └── test_group.json
└── diet_example/
    └── diet/
        ├── groups/
        │   └── test_group.json
        └── suites/
            └── builtin.json
pack.mcmeta

Note

Why are there two folders for diet and diet_example?

The namespace used for this datapack is diet_example. The diet_example folder has a subfolder called diet which houses the groups and suites folders. This is the custom data that is specifically for A Balanced Diet. On the other hand, the diet folder that houses the tags folder is using the name as a separate namespace for the purposes of adding item tags, which are read by vanilla.

New Food Group

Adding a new food group is controlled by the data/diet_example/diet/groups/test_group.json file:

{
  "icon": "minecraft:diamond",
  "color": "#ffffff",
  "order": 5,
  "default_value": 0.25,
  "gain_multiplier": 2.0,
  "decay_multiplier": 0.5,
  "beneficial": true
}

This file specifies these properties for the food group:

  • The ID for the food group is test_group, as denoted by the file name
  • The icon is a minecraft:diamond item
  • The food group's color is white (#ffffff)
  • The order is 5, which will make it appear after most food groups
  • The default value is 25% (0.25)
  • The gain multiplier is 2.0, so players gain twice as much from eating foods in this food group
  • The decay multiplier is 0.5, so the food group decays half as fast
  • The food group is beneficial, so it is considered beneficial to eat more foods in this food group

For more information on the fields and customization of food groups, please refer to Customizing Food Groups.

Note

Datapacks can't include translations, so the example datapack doesn't give test_group a display name. Until a translation is added with a resource pack, the Diet GUI shows the raw translation key groups.diet.test_group.name in place of the food group's name. See Localization for how to add one.

Adding the New Food Group to a Suite

Just creating the food group isn't enough, as now it has to be added to a diet suite in order to appear anywhere. The most relevant diet suite will be the default one, named builtin, which is configured by the data/diet_example/diet/suites/builtin.json file:

{
  "replace": false,
  "groups": [
    "test_group"
  ],
  "effects": [
    {
      "status_effects": [
        {
          "name": "minecraft:regeneration",
          "power": 2
        }
      ],
      "conditions": [
        {
          "groups": ["test_group"],
          "match": "all",
          "above": 0.8,
          "below": 1.0
        }
      ]
    }
  ]
}

This file specifies these properties for the diet suite:

  • The ID for the diet suite is builtin, as denoted by the file name. This is the same ID as the default one, so this file's purpose is to edit or override any previously stated values.
  • Because replace is false, this file's groups and effects are added to the existing builtin suite instead of replacing it.
  • The only group added is test_group
  • The effect added is a minecraft:regeneration status effect at power 2 (Regeneration III) when test_group is above 80% (0.8)

For more information on the fields and customization of diet suites, please refer to Customizing Diet Suites.

Adding an Item to a Food Group

Items are added to food groups by adding them to the relevant item tag. In the example datapack, the food group is test_group so an item tag for diet:test_group is created at data/diet/tags/items/test_group.json:

{
  "replace": false,
  "values": [
    "minecraft:apple"
  ]
}

The file name is the same as the ID for the food group and will be the name of the tag that is created. By setting replace to false, the values are added to the tag instead of replacing them. Listing minecraft:apple in the values array will add the apple item to the tag and consequently to the test_group food group.

For more information on adding foods to food groups, please refer to Categorizing Food to Groups.

Clone this wiki locally