Modify Food (Power Type)
Changes the food the entity with the power eats, without replacing it. apoli:edible_item gives one item a whole new food component, while this power scales the values an item already has. One power can double the nutrition of every item in a tag, halve the eating time of everything, or strip the effects off raw meat.
Type ID: apoli:modify_food
Fields
| Field | Type | Default | Description |
|---|---|---|---|
item_condition | Item Condition Type | optional | If set, the power only applies to items that pass this condition. Without it, the power applies to everything the entity eats. |
food_modifier | Attribute Modifier | optional | Applied to the item's nutrition (hunger points). |
food_modifiers | Array of Attribute Modifier | optional | Several modifiers applied to the item's nutrition. |
saturation_modifier | Attribute Modifier | optional | Applied to the item's saturation modifier. |
saturation_modifiers | Array of Attribute Modifier | optional | Several modifiers applied to the item's saturation modifier. |
eat_ticks_modifier | Attribute Modifier | optional | Applied to how long the item takes to eat, in ticks. |
eat_ticks_modifiers | Array of Attribute Modifier | optional | Several modifiers applied to the eating time. |
always_edible | Boolean | false | If true, matching items can be eaten on a full hunger bar. can_always_eat is accepted too. |
prevent_effects | Boolean | false | If true, the status effects the food would apply are dropped. |
replace_stack | Item Stack | optional | If set, the entity is left with this stack after eating instead of whatever the food would normally leave, such as a bowl, a bottle or nothing. |
entity_action | Entity Action Type | optional | Runs on the entity after it eats a matching item. |
item_action | Item Action Type | optional | Runs on the stack that was eaten. When that was the last item, such as a bowl of stew, it runs on a copy of the eaten item. |
The singular and plural spellings are the same field: food_modifier is read as a food_modifiers with one entry. Write whichever reads better, but not both.
How it behaves
The power hooks into eating itself, so it applies to vanilla food, modded food and food from apoli:edible_item alike. Every matching power on the entity applies in turn, so two powers that each double nutrition quadruple it.
When the entity finishes eating something:
- Every
apoli:modify_foodon the entity whoseconditionanditem_conditionpass is collected. food_modifiersandsaturation_modifiersare applied to the item's own values.prevent_effectsdrops the effect list, andreplace_stackoverrides what the item turns into.- Hunger and saturation are restored, then the remaining effects roll.
item_actionruns on the eaten stack, thenentity_actionruns on the eater.
eat_ticks_modifiers apply earlier, when the eating animation starts, because that is when the game asks how long the item takes.
replace_stack uses vanilla's "using converts to" slot, which only players have. Other entities eat the item normally and get nothing back.
Examples
{
"type": "apoli:modify_food",
"item_condition": {
"type": "apoli:ingredient",
"ingredient": {
"tag": "minecraft:fishes"
}
},
"food_modifiers": [
{
"operation": "multiply_base_multiplicative",
"value": 1
}
],
"saturation_modifiers": [
{
"operation": "multiply_base_multiplicative",
"value": 1
}
]
}This doubles both the hunger and the saturation of every item in the minecraft:fishes tag.
{
"type": "apoli:modify_food",
"item_condition": {
"type": "apoli:food"
},
"eat_ticks_modifier": {
"operation": "multiply_base_multiplicative",
"value": -0.5
},
"always_edible": true
}This halves the eating time of anything edible and lets the entity eat on a full hunger bar.
{
"type": "apoli:modify_food",
"item_condition": {
"type": "apoli:ingredient",
"ingredient": {
"tag": "minecraft:meat"
}
},
"prevent_effects": true,
"food_modifiers": [
{
"operation": "multiply_base_multiplicative",
"value": -0.5
}
],
"entity_action": {
"type": "apoli:apply_effect",
"effect": {
"effect": "minecraft:nausea",
"duration": 100
}
}
}Meat is half as filling, its own effects never apply, and eating it makes the entity nauseous.