The IItemRightClick function can be added to an Item and will be triggered when a user does rightclick with the item selected in his primary hand.

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

The IItemRightClick function is a function with the following parameters:

  • IMutableItemStack itemStack → The item that is right-clicked
  • IWorld world → The world the player is in
  • ICTPlayer player → The player doing the right-click
  • String hand → Either "OFF_HAND" or "MAIN_HAND"

The function needs to return either "SUCCESS", "PASS" or "FAIL"

ZenScript
Copy
zsItem.itemRightClick = function(stack, world, player, hand) {
    Commands.call("scoreboard players set @p name 5", player, world);
    return "Pass";
};