Skip to main content

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

FieldTypeDefaultDescription
item_conditionItem Condition TypeoptionalIf set, the power only applies to items that pass this condition. Without it, the power applies to everything the entity eats.
food_modifierAttribute ModifieroptionalApplied to the item's nutrition (hunger points).
food_modifiersArray of Attribute ModifieroptionalSeveral modifiers applied to the item's nutrition.
saturation_modifierAttribute ModifieroptionalApplied to the item's saturation modifier.
saturation_modifiersArray of Attribute ModifieroptionalSeveral modifiers applied to the item's saturation modifier.
eat_ticks_modifierAttribute ModifieroptionalApplied to how long the item takes to eat, in ticks.
eat_ticks_modifiersArray of Attribute ModifieroptionalSeveral modifiers applied to the eating time.
always_edibleBooleanfalseIf true, matching items can be eaten on a full hunger bar. can_always_eat is accepted too.
prevent_effectsBooleanfalseIf true, the status effects the food would apply are dropped.
replace_stackItem StackoptionalIf 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_actionEntity Action TypeoptionalRuns on the entity after it eats a matching item.
item_actionItem Action TypeoptionalRuns 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.
note

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:

  1. Every apoli:modify_food on the entity whose condition and item_condition pass is collected.
  2. food_modifiers and saturation_modifiers are applied to the item's own values.
  3. prevent_effects drops the effect list, and replace_stack overrides what the item turns into.
  4. Hunger and saturation are restored, then the remaining effects roll.
  5. item_action runs on the eaten stack, then entity_action runs 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.

note

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.