-
Notifications
You must be signed in to change notification settings - Fork 0
Categorizing Food to Groups
This page explains how to assign foods to food groups using tags.
Food classification into groups is done through item tags. Each food group has an item tag named diet:[group-name], and any item in that tag belongs to that food group. For a general overview of the tag system, see the tags page on the Minecraft Wiki.
Note
If the enableDataFoodValues option is enabled in the server config, per-food values take priority over tags (see Setting Food Values). Tags are still used as a fallback for any food that doesn't have a food value.
Tag files are .json files located in the data/diet/tags/items/ folder of a datapack. For help creating a datapack, see Using Datapacks.
The file name must match the ID of the food group. For example, you would add items to the fruits food group with the data/diet/tags/items/fruits.json file. Food group tag files should always be part of the diet namespace folder, even if other files in the datapack use a different namespace.
In the tag file you've created, copy this text:
{
"replace": false,
"values": []
}The replace value dictates whether you're just adding items to a tag or completely overriding the tag with new items. I recommend leaving this false unless you know what you're doing. values is where you list all of the items that you want to add to the group. For example, if you'd like to add an item called "examplemod:pizza":
{
"replace": false,
"values": ["examplemod:pizza"]
}You can list multiple values here, separated by commas:
{
"replace": false,
"values": ["examplemod:pizza", "examplemod:cheese"]
}To check the registry name of an item, toggle advanced tooltips in-game using F3+H and hover over the item.
If you want to remove items from a tag, Forge provides an additional remove array:
{
"replace": false,
"values": ["examplemod:pizza", "examplemod:cheese"],
"remove": ["examplemod:fish"]
}You can verify that you've properly added the item to the group by looking at the item's tooltip, where it will list the food groups it belongs to.
Adding items to this tag prevents the item from contributing its food groups as a crafting component of other items. This is useful for adding foods that may have food groups themselves but should not contribute to any other item's food groups, such as condiments or seasoning that conceptually do not add enough to a food item to also add its food groups.
Note that this tag is only relevant if A Balanced Diet's default value generator is turned on with the generateGroupsForEmptyItems option in the server config (enabled by default). Otherwise, food groups rely solely on the item's tagging information rather than its crafting components.
Adding items to this tag forcibly adds food groups to the item regardless of whether it is considered edible or not. This is useful for items like cakes that are essentially blocks that proxy food items only when placed and interacted with. The cake itself is not edible but it should still provide information about its food groups, so it should be placed in this tag in addition to its food group tags in order to provide that information. The tooltip for such foods will only display its food groups and not the value provided (since such information cannot be obtained directly from the item itself).