Skip to Content
DocumentationCustom contentCustom items

Creating a Custom Item

The complete item class will look like this:

ItemCustomExample.java
import cn.nukkit.item.customitem.CustomItemDefinition; import cn.nukkit.item.customitem.ItemCustom; import cn.nukkit.network.protocol.types.inventory.creative.CreativeItemCategory; public class ItemCustomExample extends ItemCustom { public ItemCustomExample() { super("lumi:example_item", "Example Item", "diamond"); } @Override public CustomItemDefinition getDefinition() { return CustomItemDefinition.simpleBuilder(this, CreativeItemCategory.ITEMS).build(); } }

Specify the item’s string identifier, name, and texture:

ItemCustomExample.java
public class ItemCustomExample extends ItemCustom { public ItemCustomExample() { super("lumi:example_item", "Example Item", "diamond"); }

The identifier must strictly follow this format: namespace:identifier. Example: custom:myitem.

Create the item definition:

ItemCustomExample.java
public class ItemCustomExample extends ItemCustom { public ItemCustomExample() { super("lumi:example_item", "Example Item", "diamond"); } @Override public CustomItemDefinition getDefinition() { return CustomItemDefinition.simpleBuilder(this, CreativeItemCategory.ITEMS).build(); }

The item definition allows you to specify all of its properties and parameters, such as its creative inventory category, rendering offset, and other properties.

You can set additional item properties using NBT tags via the CustomItemDefinition.SimpleBuilder#customBuild method.

Last updated on