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

importio.github.kiber2009.plugin.contentapi.api.item.CustomItem;
importio.github.kiber2009.plugin.contentapi.api.item.properties.Properties;
publicclassMyItemextendsCustomItem {
publicMyItem(NamespacedKeyid) {
super(id, newProperties());
}
}

Registration

  1. Create a local registry
importio.github.kiber2009.plugin.contentapi.api.item.CustomItem;
importio.github.kiber2009.plugin.contentapi.api.registry.PluginLocalRegistry;
privatestaticfinalPluginLocalRegistry<CustomItem> ITEMS = newPluginLocalRegistry<>(YOUR_PLUGIN_INSTANCE);
  1. Register your item in the local registry
privatestaticfinalMyItemMY_ITEM = ITEMS.register("my_item", MyItem::new);
  1. Register your local registry in the global registry
importio.github.kiber2009.plugin.contentapi.registry.GlobalRegistry;
publicvoidonEnable() {
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

ItemStackoneItem = MY_ITEM.getItemStack();
ItemStackfiveItems = MY_ITEM.getItemStack(5);

Interaction

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

Clone this wiki locally