Home Getting Started With Scripts Using this wiki Commands CTGUI Global functions Bracket Handlers

IItemFoodEaten

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

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;

Parameters

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.

Examples

script.zs
#loader contenttweaker
import mods.contenttweaker.VanillaFactory;
var item = VanillaFactory.createItemFood("suspicious_soup", 4);
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();