-
Notifications
You must be signed in to change notification settings - Fork 0
Customizing Food Groups
This page explains how to create and customize food groups.
Food groups are ways that players can categorize and differentiate the different types of food available to them. Some foods may have one or multiple food groups. Eating food will increase the player's percentage of each food group that is associated with the food item.
Groups are completely customizable through datapacks, allowing users complete control over which food groups are available and how many are tracked. If you are unfamiliar with datapacks, see Using Datapacks first.
Tip
If using the Built-in Food Groups without changes, you can skip this page and go straight to Customizing Diet Suites.
Warning
Creating a food group will not automatically make it appear in-game. Food groups will only appear once assigned to a diet suite (see Customizing Diet Suites) and only for players using that suite.
Food groups are defined as .json files located in the data/[namespace]/diet/groups/ folder of the datapack.
The file name is the food group's ID, which is used to refer to the food group in diet suites, item tags, and translation keys. For example, a fruits food group is defined by a data/[namespace]/diet/groups/fruits.json file.
Note
[namespace] should be replaced by the namespace chosen for this portion of the datapack. If this is part of a mod, the namespace is usually the mod ID. If this is part of a user-defined datapack, the namespace can be any lowercase string with no special characters.
The food group's .json file includes a top-level JSON object that holds various fields related to that food group.
| Field | Type | Default | Required | Description |
|---|---|---|---|---|
icon |
string | "minecraft:air" |
No | The registry name of the item used to represent the food group. |
color |
string | "#ffffff" |
No | The color, as an integer or hexadecimal string, used to represent the food group. |
order |
integer | 1 |
No | The order the food groups will appear in the Diet GUI, lower numbers appear higher. |
default_value |
decimal | 0.0 |
No | The starting value of the food group, as a percentage, between 0.0 and 1.0. |
gain_multiplier |
decimal | 1.0 |
No | The multiplier to how much value is added to the food group when food is eaten. |
decay_multiplier |
decimal | 1.0 |
No | The multiplier to how much the food group decays when hungry. |
beneficial |
boolean | true |
No | If true, the food group is considered beneficial to have in higher amounts. |
{
"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 icon is a
minecraft:diamonditem - The 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
Existing food groups from other sources, such as A Balanced Diet itself, can be edited by creating a food group file with the same ID. Only the fields listed in the new file are changed, and every other field keeps its existing value.
A Balanced Diet natively provides data for a fruits food group, which has a default_value of 0.0. In order to increase the default value to 0.5, create a fruits.json food group file in the datapack with the contents:
{
"default_value": 0.5
}This will replace the pre-existing default value with the new one of 0.5. However, make sure the namespace of the new fruits.json file is not the same as the default diet namespace, because that will fully overwrite the original. This will lead to an incomplete food group registration.
The default food groups have built-in translations provided, but custom food groups will need to have their own created.
The key is: groups.diet.[group-name].name.
Example translation entry:
"groups.diet.grains.name": "Grains"A group description can be added using the key groups.diet.[group-name].tooltip. If present, the description will show above the list of effects when hovering over the food group's bar in the Diet GUI.
These entries need to be placed in the localization files of a custom resource pack. For further information about creating a resource pack, please refer to this guide on the Minecraft Wiki.
These food groups are built into A Balanced Diet natively and can be added to diet suites (see Customizing Diet Suites) or individually customized by creating a new datapack file that overrides its contents.
fruits.json
{
"icon": "minecraft:apple",
"color": "#d41c53",
"order": 0,
"default_value": 0.0,
"gain_multiplier": 1.0,
"decay_multiplier": 1.0,
"beneficial": true
}grains.json
{
"icon": "minecraft:bread",
"color": "#d4a31c",
"order": 0,
"default_value": 0.0,
"gain_multiplier": 1.0,
"decay_multiplier": 1.0,
"beneficial": true
}proteins.json
{
"icon": "minecraft:cooked_beef",
"color": "#d4781c",
"order": 0,
"default_value": 0.0,
"gain_multiplier": 1.0,
"decay_multiplier": 1.0,
"beneficial": true
}vegetables.json
{
"icon": "minecraft:carrot",
"color": "#31d41c",
"order": 0,
"default_value": 0.0,
"gain_multiplier": 1.0,
"decay_multiplier": 1.0,
"beneficial": true
}sugars.json
{
"icon": "minecraft:honey_bottle",
"color": "#ff8fe9",
"order": 10,
"default_value": 0.0,
"gain_multiplier": 1.0,
"decay_multiplier": 1.0,
"beneficial": true
}