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.

패키지 임포트하기

Link to 패키지-임포트하기

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();