CustomItem functions

rightClick(PlayerInteractionEvent, UUID)

Triggered when using the right mouse button with your item in hand. Can be cancelled manually. It can be cancelled before execution via event.setCancelled if you intercept the event or use.

Performed for both hands, allowing logic for when the player holds your item in.

Example:

@Override
public void rightClick(PlayerInteractEvent event, UUID uuid) {
    event.getPlayer().sendMessage("Wow, right click.");
}

leftClick(PlayerInteractionEvent, UUID)

Basicly the same thing as rightClick but its left click.

Example:

@Override
public void leftClick(PlayerInteractEvent event, UUID uuid) {
    event.getPlayer().sendMessage("Wow, left click.");
}

rightClickOnEntity(PlayerInteractEntityEvent, UUID)

Similar to rightClick, but triggered when a player interacts with a creature. The rightClick event will not be triggered, but this event can be canceled like rightClick, and it also applies to both hands.

recipe(NamespacedKey, ItemStack)

The recipe method is used to define a crafting recipe for a custom item in a plugin. It requires two parameters:

  • NamespacedKey key: A unique identifier for the recipe. This key is crucial for registering the recipe within the game.

  • ItemStack item: The resultant item of the crafting recipe. It is mandatory that this item corresponds to the desired outcome of the crafting process.

If either the key or the item is incorrectly specified, the recipe manager will not register the recipe, and the item will not be available in the game. An IllegalStateException will be thrown if the key and item are not used correctly in the recipe's construction. Utilize utility methods like CustomItemUtils#getExactChoiceFromID(String) or CustomItemUtils#getExactChoiceFromItem(CustomItem) to ensure accurate choice definition.

getImprovedItemStack(ItemStack)

Here you can add minecraft attributes to your item.

You must remeber that name, description and id already in item given in argument.

In return you must give back improved ItemStack with changes that you made.

customModelID()

Indentifies that u want use your own model for this item.

You need to make your own texturepack for this function or else nothing will happen.

Last updated