The IItemFoodEaten function is called whenever the associated food item is eaten. Note that this event will not fire if the item already has a provided IItemUseFinish.

Importing the package

Link to importing-the-package

It might be required for you to import the package if you encounter any issues, so better be safe than sorry and add the import.
import mods.contenttweaker.IItemFoodEaten;

The IItemFoodEaten is a function with the following parameters (In this order):

  • IMutableItemStack mutableItemStack → The food item being eaten.
  • IWorld world → The world the player is in
  • CTPlayer player → The player eating the food.
ZenScript
Copy
#loader contenttweaker

import mods.contenttweaker.VanillaFactory;

var item = VanillaFactory.createItem("suspicious_soup");

item.healAmount = 4;
item.saturation = 1.5;
item.onItemFoodEaten = function(stack, world, player) {
    if (!world.isRemote()) {
        player.addPotionEffect(<potion:minecraft:weakness>.makePotionEffect(60, 1));
    }
};
item.register();