Skip to Content

Creating a Custom Block

The complete block class will look like this:

BlockCustomExample.java
import cn.nukkit.Player; import cn.nukkit.block.Block; import cn.nukkit.block.customblock.CustomBlock; import cn.nukkit.block.customblock.CustomBlockDefinition; import cn.nukkit.network.protocol.types.inventory.creative.CreativeItemCategory; public class BlockCustomExample extends Block implements CustomBlock { @Override public String getName() { return "Example Block"; } @Override public CustomBlockDefinition getDefinition() { return CustomBlockDefinition.builder(this, "stone", CreativeItemCategory.ITEMS) .name("Example Block") .build(); } @Override public int getId() { return CustomBlock.super.getId(); } @Override public String getIdentifier() { return "lumi:example_block"; } }

Specify the block name and its string identifier:

BlockCustomExample.java
public class BlockCustomExample extends Block implements CustomBlock { @Override public String getName() { return "Example Block"; } @Override public int getId() { return CustomBlock.super.getId(); } @Override public String getIdentifier() { return "lumi:example_block"; }

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

The public int getId() method must remain unchanged in all blocks and return CustomBlock.super.getId(). This allows Lumi to generate the block’s numeric identifier automatically. Specifying it manually may break all custom blocks on the server.

Create the block definition:

ItemCustomExample.java
public class BlockCustomExample extends Block implements CustomBlock { @Override public CustomBlockDefinition getDefinition() { return CustomBlockDefinition.builder(this, "stone", CreativeItemCategory.ITEMS) .name("Example Block") .build(); } }

The block definition allows you to specify all of its properties and parameters, such as its creative inventory category, materials (textures), and other properties.

You can set additional block properties using NBT tags via the CustomBlockDefinition.Builder#customBuild method.

All methods for defining materials, geometry, and other properties can be found here .

Last updated on