Skip to Content
ДокументацияПользовательский контентКастомные предметы

Создание кастомного предмета

Полный класс предмета будет выглядеть таким образом:

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(); } }

Укажите строчный идентификатор предмета, название предмета и его текстуру:

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

Идентификатор должен быть строго в таком формате: пространство_имен:идентификатор. Пример: custom:myitem.

Создайте определение предмета:

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(); }

В определении предмета можно указать все его свойства и параметры, такие как категория в креативном инвентаре, смещение рендеринга и другие свойства.

Вы можете задать другие свойства предмета с помощью NBT-тегов с помощью метода CustomItemDefinition.SimpleBuilder#customBuild

Last updated on