How-to: Add Custom Items
Library of Exile does not mandate a specific item registration pattern, but it provides
RelicItem as a base class for relic items and integrates with Forge's DeferredRegister
through OrderedModConstructor.
Register a basic item
// In your OrderedModConstructor subclass:
public static final DeferredRegister<Item> ITEMS =
DeferredRegister.create(ForgeRegistries.ITEMS, "my_mod");
public static final RegistryObject<Item> MY_ITEM =
ITEMS.register("my_item", () -> new Item(new Item.Properties()));
@Override
public void registerDeferredContainers(IEventBus bus) {
ITEMS.register(bus);
}
Register a RelicItem
RelicItem is a minimal single-stack item intended to hold relic capability data:
public static final RegistryObject<Item> AMULET =
ITEMS.register("amulet", RelicItem::new);
To link it to the relic system, create a matching RelicType JSON — see
Add Relics.
Register a custom RelicItem subclass
If you need tooltips, special right-click behaviour, or other item logic:
public class RingItem extends RelicItem {
@Override
public void appendHoverText(ItemStack stack, @Nullable Level level,
List<Component> tooltip, TooltipFlag flag) {
super.appendHoverText(stack, level, tooltip, flag);
tooltip.add(Component.literal("A powerful ring").withStyle(ChatFormatting.GOLD));
}
}
// Registration:
public static final RegistryObject<Item> RING =
ITEMS.register("ring", RingItem::new);
Register a BlockItem
For items that place blocks, register both the block and the item:
public static final DeferredRegister<Block> BLOCKS =
DeferredRegister.create(ForgeRegistries.BLOCKS, "my_mod");
public static final RegistryObject<Block> MY_BLOCK =
BLOCKS.register("my_block", () -> new Block(BlockBehaviour.Properties.of()));
public static final RegistryObject<Item> MY_BLOCK_ITEM =
ITEMS.register("my_block", () -> new BlockItem(MY_BLOCK.get(), new Item.Properties()));
Register both DeferredRegister instances in registerDeferredContainers:
@Override
public void registerDeferredContainers(IEventBus bus) {
ITEMS.register(bus);
BLOCKS.register(bus);
}
Provide item models and textures
Library of Exile does not handle model generation. Add your own JSON model files under:
src/main/resources/assets/my_mod/models/item/my_item.json
src/main/resources/assets/my_mod/textures/item/my_item.png
A standard generated model:
{
"parent": "item/generated",
"textures": {
"layer0": "my_mod:item/my_item"
}
}
Provide item language entries
// src/main/resources/assets/my_mod/lang/en_us.json
{
"item.my_mod.my_item": "My Item"
}
Notes
RelicItemcallsstacksTo(1)in its constructor — relic items are always non-stackable.- Items registered with Forge's
DeferredRegisterare available afterFMLCommonSetupEvent. Do not try to resolveRegistryObject.get()before that point. ExileKeyHolder.createItems()is an internal helper used by the library's own content. Prefer plainDeferredRegisterfor your own mod's items to keep the code straightforward.