-
Notifications
You must be signed in to change notification settings - Fork 0
Customizing Diet Suites
This page explains how to create and customize diet suites and the effects they provide.
Diet suites are collections of food groups and effects. The effects get applied to a player based on the value of their food groups. Players can only have one diet suite at a time, but an instance can have as many diet suites as it needs. Suites exist on a per-player basis so players can use different suites (see Switching Suites).
Suites are divided into food groups and effects. Effects are further divided into conditions, attribute modifiers, and status effects (called potion effects in game), and can optionally include a quality color and a notification.
Diet suites are defined as .json files located in the data/[namespace]/diet/suites/ folder of the datapack.
The file name is the suite's ID. An ID can be any lowercase string with no special characters. To customize or replace the default diet suite, name the file builtin.json. The default suite can be changed with the server config's defaultSuite option.
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 suite's .json file includes a top-level JSON object that holds three potential fields.
| Field | Type | Default | Required | Description |
|---|---|---|---|---|
replace |
boolean | false |
No | If true, the file will override suites of the same ID instead of adding them together. |
groups |
string[] | [] |
No | An array of food group IDs (see Customizing Food Groups). |
effects |
object[] | [] |
No | An array of effects to apply to the player (see Customizing Effects). |
Dietary effects are attribute modifiers or status effects applied to players when certain conditions are met. A single effect entry can have multiple conditions, attribute modifiers, and status effects, along with an optional quality color and notification.
Warning
Each effect needs at least one condition and at least one attribute modifier, status effect, or notification. If any effect is missing these, the whole suite file will fail to load and print an error to the log.
A condition is an entry defining a test that needs to pass in order to activate the corresponding effect. There can be multiple conditions for a single effect, and all conditions must pass in order to activate the effect.
{
"effects": [
{
"conditions": [
{
"groups": ["sugars", "proteins"],
"match": "all",
"above": 0.8,
"below": 1.0
}
]
}
]
}| Field | Type | Default | Required | Description |
|---|---|---|---|---|
groups |
string[] | [] |
No | The IDs of the food groups that this condition tests against (see Customizing Food Groups). |
above |
decimal | 0.0 |
No | A decimal value between 0.0 and 1.0 that indicates the lower bound that the value must be at or above. |
below |
decimal | 1.0 |
No | A decimal value between 0.0 and 1.0 that indicates the upper bound that the value must be at or below. |
match |
string | "any" |
No | The match method used for the condition testing. |
Possible match values:
-
"all"- Condition passes if all the groups meet the threshold. -
"any"- Condition passes if any of the groups meet the threshold. -
"average"- Condition passes if the average value of the groups meets the threshold. -
"none"- Condition passes if none of the groups meet the threshold. -
"every"- Condition passes if at least one group meets the threshold. In addition, each group past the first that meets the threshold adds theincrementof every attribute modifier and status effect in the entry.- Example: If three groups pass an
"every"test, then a Strength I status effect (powerof0, defaultincrementof1) becomes Strength III.
- Example: If three groups pass an
An attribute modifier represents a direct modifier to an entity attribute. For more information on attributes, see the attributes page on the Minecraft Wiki.
{
"effects": [
{
"attributes": [
{
"name": "minecraft:generic.movement_speed",
"operation": "multiply_base",
"amount": 0.25
}
]
}
]
}| Field | Type | Default | Required | Description |
|---|---|---|---|---|
name |
string | — | Yes | The namespaced registry name of the entity attribute to apply this entry on. |
operation |
string | "add" |
No | The type of operation to perform on the entity attribute. |
amount |
decimal | 1.0 |
No | The amount to use for the operation on the attribute modifier. |
increment |
decimal | Same as amount
|
No | The amount added for each additional group that passes an "every" condition beyond the first. |
Possible operation values:
-
"multiply_total"- Increment the attribute by (value * amount) -
"multiply_base"- Increment the attribute by (base * amount) -
"add"- Increment the attribute by the amount
List of vanilla Minecraft entity attribute names:
- Max Health -
"minecraft:generic.max_health" - Knockback Resistance -
"minecraft:generic.knockback_resistance" - Movement Speed -
"minecraft:generic.movement_speed" - Attack Damage -
"minecraft:generic.attack_damage" - Attack Knockback -
"minecraft:generic.attack_knockback" - Attack Speed -
"minecraft:generic.attack_speed" - Armor -
"minecraft:generic.armor" - Armor Toughness -
"minecraft:generic.armor_toughness" - Luck -
"minecraft:generic.luck"
A status effect entry applies a status effect to the player.
{
"effects": [
{
"status_effects": [
{
"name": "minecraft:hunger",
"power": 2
}
]
}
]
}| Field | Type | Default | Required | Description |
|---|---|---|---|---|
name |
string | — | Yes | The namespaced registry name of the status effect to apply. |
power |
integer | 0 |
No | The strength of the status effect, where 0 is level I, 1 is level II, and so on. |
increment |
integer | 1 |
No | The power added for each additional group that passes an "every" condition beyond the first. |
The quality field sets a quality color, which is drawn over the relevant section of the food group's bar in the Diet GUI. This is used to show players what levels provide positive or negative effects.
The color will fill the sections of the bar that match its conditions. If multiple colors overlap, they are averaged with one another.
{
"effects": [
{
"status_effects": [
{
"name": "minecraft:hunger",
"power": 2
}
],
"conditions": [
{
"groups": ["sugars"],
"match": "all",
"above": 0.8,
"below": 1.0
}
],
"quality": "#FF0000"
}
]
}In this example, the sugars bar is colored red from 80% to 100%, to show that negative effects are applied during that range.
| Field | Type | Default | Required | Description |
|---|---|---|---|---|
quality |
string | "#FFFFFF" |
No | The hex color that will be drawn over the effect's range. |
Quality colors are only shown when the quality view is visible. The client config controls when this is shown with the qualityDisplayMode option:
-
NONE- Never display quality (default) -
HOVER- Display quality only when hovering a bar -
TOGGLE- Display a toggle button that enables quality on all bars -
BOTH- Enable both hover and toggle behaviors
Notifications send a chat message to the player when the effect starts or stops. An effect can have a notification without any attribute modifiers or status effects, so it sends a message without doing anything else.
{
"effects": [
{
"status_effects": [
{
"name": "minecraft:hunger",
"power": 2
}
],
"conditions": [
{
"groups": ["sugars"],
"match": "all",
"above": 0.8,
"below": 1.0
}
],
"notification": {
"notification_id": "sugars_80_100",
"notification_sets": ["sugars_negative", "negative"],
"message": "notification.diet.sugars_80_100",
"trigger": "enter",
"default_frequency": "always"
}
}
]
}| Field | Type | Default | Required | Description |
|---|---|---|---|---|
notification_id |
string | — | Yes | The notification's unique ID. |
message |
string | — | Yes | The translation key of the notification's message (see Notification Localization). |
notification_sets |
string[] | [] |
No | The IDs of each set this notification belongs to, for letting players mute multiple notifications at once. |
trigger |
string | "enter" |
No | The trigger that makes the notification appear. |
default_frequency |
string | The notificationsDefaultFrequency config value |
No | How many times the notification will appear ("always", "once", or "never"). |
Possible trigger options:
-
"enter"- When the player enters the threshold (default) -
"rise_into"- When the player enters the threshold from below -
"fall_into"- When the player enters the threshold from above -
"rise_through"- When the player enters or passes through the threshold from below -
"fall_through"- When the player enters or passes through the threshold from above -
"exit"- When the player leaves the threshold -
"rise_out"- When the player leaves the threshold by rising above it -
"fall_out"- When the player leaves the threshold by falling below it -
"all"- When the player enters, leaves, or passes through the threshold
Possible default_frequency options:
-
"always"- The notification appears every time its trigger occurs, along with a button to mute it -
"once"- The notification appears once and then sets itself to"never" -
"never"- The notification does not appear unless triggered manually with the/diet notifycommand
The message field is a translation key, which means the text it shows comes from a resource pack's language files (see Localization). In the message, every appearance of %s is replaced with the name of a food group listed in the effect's conditions. Multiple food groups will display in order but can be specifically named using %1$s, %2$s, etc. instead of %s.
Localization can also be applied to notifications and notification sets to give them display names for the diet notification commands and mute menu:
-
notification.diet.id.[notification-id].nameis the name of a notification -
notification.diet.set.[set-id].nameis the name of a notification set
Example translation entries:
"notification.diet.sugars_80_100": "%s high: you move faster, but are hungry",
"notification.diet.id.sugars_80_100.name": "Sugars High",
"notification.diet.set.negative.name": "Negative"When a notification with the "always" frequency appears, its message will include a [Mute] button. Clicking the button opens the mute menu, with options to mute:
- This specific notification
- All notifications for one of this notification's sets
- All notifications for one of this notification's food groups
- All diet notifications
Each player's mute settings are saved separately. Players can also change their own settings with the /diet notifications command.
{
"replace": false,
"groups": [
"fruits",
"grains",
"proteins",
"sugars",
"vegetables"
],
"effects": [
{
"attributes": [
{
"name": "minecraft:generic.max_health",
"operation": "add",
"amount": 2.0
}
],
"conditions": [
{
"groups": ["proteins", "fruits", "vegetables", "grains"],
"match": "all",
"above": 0.8,
"below": 1.0
}
]
},
{
"status_effects": [
{
"name": "minecraft:hunger",
"power": 2
}
],
"conditions": [
{
"groups": ["sugars"],
"match": "all",
"above": 0.8,
"below": 1.0
}
]
}
]
}This file specifies these effects for the diet suite:
-
2.0additionalmax_healthwhenalltheproteins,vegetables,grains, andfruitsfood groups are above 80% (0.8) and below or equal to 100% (1.0) -
hungerat power2(Hunger III) whensugarsis above 80% (0.8) and below or equal to 100% (1.0)
This is the built-in diet suite that is configured by default, aptly named builtin.
builtin.json
{
"replace": false,
"groups": [
"fruits",
"grains",
"proteins",
"sugars",
"vegetables"
],
"effects": [
{
"attributes": [
{
"name": "minecraft:generic.max_health",
"operation": "add",
"amount": 2.0
},
{
"name": "minecraft:generic.attack_damage",
"operation": "add",
"amount": 2.0
},
{
"name": "minecraft:generic.attack_speed",
"operation": "multiply_total",
"amount": 0.1
}
],
"notification": {
"notification_id": "all_80_100",
"notification_sets": ["all_positive", "positive"],
"message": "notification.diet.all_80_100",
"trigger": "enter",
"default_frequency": "once"
},
"conditions": [
{
"groups": ["proteins", "fruits", "vegetables", "grains"],
"match": "all",
"above": 0.8,
"below": 1.0
}
]
},
{
"attributes": [
{
"name": "minecraft:generic.max_health",
"operation": "add",
"amount": 2.0
},
{
"name": "minecraft:generic.knockback_resistance",
"operation": "add",
"amount": 0.10
},
{
"name": "minecraft:generic.armor_toughness",
"operation": "add",
"amount": 1.0
}
],
"conditions": [
{
"groups": ["proteins", "fruits", "vegetables", "grains"],
"match": "every",
"above": 0.8,
"below": 1.0
}
],
"notification": {
"notification_id": "any_80_100",
"notification_sets": ["any_positive", "positive"],
"message": "notification.diet.any_80_100",
"trigger": "enter",
"default_frequency": "once"
},
"quality": "#00FF00"
},
{
"attributes": [
{
"name": "minecraft:generic.movement_speed",
"operation": "multiply_base",
"amount": 0.25
}
],
"status_effects": [
{
"name": "minecraft:hunger",
"power": 2
}
],
"conditions": [
{
"groups": ["sugars"],
"match": "all",
"above": 0.8,
"below": 1.0
}
],
"notification": {
"notification_id": "sugars_80_100",
"notification_sets": ["sugars_negative", "negative"],
"message": "notification.diet.sugars_80_100",
"trigger": "enter",
"default_frequency": "always"
},
"quality": "#FF0000"
}
]
}Each player starts with the configured default suite (builtin by default). Suites can be changed in-game using the /diet suite command:
-
/diet suite <player>shows the player's current suite -
/diet suite <player> <suite>switches the player to another suite
The same functionality can be accessed with the API through DietApi.getInstance().getSuite(player) and DietApi.getInstance().setSuite(player, suite).