IItemInteractionForEntity

Link to iiteminteractionforentity

The IItemInteractionForEntity function can be added to an Item and will be triggered when a player right clicks on an entity with the item.

NOTE: This class will not exist until a ContentTweaker 1.12 version newer than 4.10.0 is built and released. For now, this file is kept for archival purposes, and this notice will be removed when ContentTweaker 1.12 is updated.

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.IItemInteractionForEntity;

The IItemInteractionForEntity function is a function with the following parameters:

The function needs to return either true or false

ZenScript
Copy
#loader contenttweaker

import mods.contenttweaker.VanillaFactory;
import mods.contenttweaker.Item;
import mods.contenttweaker.IItemInteractionForEntity;
import crafttweaker.entity.IEntityLivingBase;

var sheep_remover = VanillaFactory.createItem("sheep_remover");
sheep_remover.itemInteractionForEntity = function(stack, player, target, hand) {
    if target.definition.id == "minecraft:sheep" {
        target.removeFromWorld();
        stack.shrink(1);
        return true;
    }
    return false;
};
sheep_remover.register();