-
Notifications
You must be signed in to change notification settings - Fork 0
Custom items
Kiber2009 edited this page Jul 4, 2026
·
2 revisions
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());
}
}- 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);- Register your item in the local registry
private static final MyItem MY_ITEM = ITEMS.register("my_item", MyItem::new);- Register your local registry in the global registry
import io.github.kiber2009.plugin.contentapi.registry.GlobalRegistry;
public void onEnable() {
GlobalRegistry.ITEMS.register(ITEMS);
}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
NamespacedKeypassed to constructor
You can get an ItemStack of your custom item by calling getItemStack method
ItemStack oneItem = MY_ITEM.getItemStack();
ItemStack fiveItems = MY_ITEM.getItemStack(5);You can add custom interaction logic to your custom item by overriding onInteract method