This guide covers the advanced Custom Item API for creating items with custom client-side properties
such as custom textures, display names, render offsets, and special flags.
What you will learn:
How to create custom items with CustomItemDefinitionGenerator
Configuring textures, display names, and render offsets
Special item flags (foil, off-hand, cooldown)
Auto-detection for armor, tools, and food items
Server Module Required
The Custom Item API requires access to the server module. In your build.gradle.kts, you must set
apiOnly = false in the allay block:
allay{apiOnly=false// Required for Custom Item API// ... other settings}
Note that internal APIs may change between versions. See AllayGradle documentation
for more details.
Prerequisites
Before diving into custom items, make sure you understand the basics of the Item API covered in
Item API Tutorial.
The Custom Item API uses a builder pattern through CustomItemDefinitionGenerator. You configure
properties like texture, display name, render offsets, and various flags. The system automatically
detects and configures special item types (armor, tools, food).
CustomItemDefinitionGenerator.builder().texture("special_item").displayName("Special Item").foil(true).canDestroyInCreative(false).allowOffHand(true).cooldown(1)// 1 second cooldown.build()
// For a 32x32 texture (2x the normal 16x16)CustomItemDefinitionGenerator.builder().texture("big_texture_item").renderOffsets(RenderOffsets.textureSize(32)).build()// For a 48x48 textureCustomItemDefinitionGenerator.builder().texture("huge_texture_item").renderOffsets(RenderOffsets.textureSize(48)).build()
Texture Size
The texture size must be a multiple of 16. Common values: 16 (default), 32, 48, 64.
AllayItemType.builder(CustomFoodImpl.class).identifier("myplugin:magic_apple").addComponent(ItemEdibleComponentImpl.class)// Auto-detected.itemDefinitionGenerator(CustomItemDefinitionGenerator.builder().texture("magic_apple").displayName("Magic Apple").foil(true)// Like enchanted golden apple.build()).build();
AllayItemType.builder(ThrowableItemImpl.class).identifier("myplugin:magic_orb").itemData(ItemData.builder().maxStackSize(16).build()).itemDefinitionGenerator(CustomItemDefinitionGenerator.builder().texture("magic_orb").displayName("Magic Orb").allowOffHand(true).cooldown(1)// 1 second cooldown.build()).build();
Texture names must match entries in your resource pack's textures/item_texture.json.
Use textureSize() for Large Items
For items with textures larger than 16x16, use RenderOffsets.textureSize() for correct scaling.
Let Auto-Detection Work
Don't manually configure armor slots or tool properties - add the appropriate components
and let the generator detect them automatically.
Cooldown Values
Cooldown is in seconds. Very short cooldowns may not be noticeable.
Display Name Localization
For translatable display names, use translation keys that start with the appropriate prefix.
The display name supports the @MayContainTrKey annotation pattern.
Resource Pack Required
Custom items require a resource pack with the appropriate textures. Without it,
items will appear with missing texture placeholders.