Skip to content

Custom items

Kiber2009 edited this page Jul 4, 2026 · 2 revisions

Basics

To create custom item, you need to extend CustomItem class

import io.github.kiber2009.plugin.contentapi.api.item.CustomItem;
import io.github.kiber2009.plugin.contentapi.api.item.properties.Properties;

public class MyItem extends CustomItem {
    public MyItem(NamespacedKey id) {
        super(id, new Properties());
    }
}

Registration

  1. Create a local registry
import io.github.kiber2009.plugin.contentapi.api.item.CustomItem;
import io.github.kiber2009.plugin.contentapi.api.registry.PluginLocalRegistry;

private static final PluginLocalRegistry<CustomItem> ITEMS = new PluginLocalRegistry<>(YOUR_PLUGIN_INSTANCE);
  1. Register your item in the local registry
private static final MyItem MY_ITEM = ITEMS.register("my_item", MyItem::new);
  1. Register your local registry in the global registry
import io.github.kiber2009.plugin.contentapi.registry.GlobalRegistry;

public void onEnable() {
    GlobalRegistry.ITEMS.register(ITEMS);
}

Properties

Properties is a builder-like class that allows you to set custom properties of your item.

By default, all custom items uses minecraft:nether_brick as a material. You can change material by providing it to Properties constructor. In most cases, custom items do not inherit the properties of their materials.

Default name and model are based on NamespacedKey passed to CustomItem constructor:

  • Name: translatable component item.NAMESPACE.KEY
  • Model: same as NamespacedKey passed to constructor

Getting an ItemStack

You can get an ItemStack of your custom item by calling getItemStack method

ItemStack oneItem = MY_ITEM.getItemStack();
ItemStack fiveItems = MY_ITEM.getItemStack(5);

Interaction

You can add custom interaction logic to your custom item by overriding onInteract method

Clone this wiki locally