Fix "Duplicate registration" and "Adding duplicate key" in a mod
Each id in a registry is meant to be used once. What happens when a mod registers examplemod:example_item twice
depends on the loader.
On NeoForge, the DeferredRegister refuses the second entry and the game stops while it builds your mod:
Failed to create mod instance. ModID: examplemod, class com.example.examplemod.ExampleModjava.lang.ExceptionInInitializerError: nullCaused by: java.lang.IllegalArgumentException: Duplicate registration example_item at net.neoforged.neoforge.registries.DeferredRegister.register(DeferredRegister.java:230) ... at com.example.examplemod.registry.ModItems.<clinit>(ModItems.java:16)The last line in your own package, ModItems.java:16 here, is the second registration.
On Fabric, items go straight into Minecraft’s registry. Its code builds an error for this,
Adding duplicate key '...' to registry, but in 1.21.1 it doesn’t throw it outside a debugging session. A Fabric 1.21.1
server with the same id registered twice started normally and logged nothing. Both objects exist, but the id leads to
only one of them, so the bug shows up later as the wrong item, block or behaviour.
Checked on 19 November 2026 on NeoForge 1.21.1 and Fabric 1.21.1 servers. The NeoForge log is shortened.
Common causes
Section titled “Common causes”- The code that registers runs twice. For example, a method that calls
Registry.registeris called from both the main and the client initializer. Registrations in static fields run once, however often the class is touched. - Two entries with the same name, often from copying one line and changing only the field name:
register("ruby", ...)for bothRUBYandRUBY_BLOCK. - A block item registered by hand and by a helper. Some setups register the item for each block automatically, so a second, manual registration of the same id clashes.
- Take the id from the message (
example_item), or the id of the thing that behaves wrongly. - Search your code for that name in quotes. Every match that registers it is a candidate; keep one.
- If there is only one, set a breakpoint or a log line on it: it’s being called twice. Remove the second call.
On NeoForge, each DeferredRegister is attached to the mod event bus once, in the mod’s constructor
(NeoForge: registries). Attaching it a second time fails with
its own error, Cannot register DeferredRegister to more than one event bus.
In Linen
Section titled “In Linen”Crash Doctor in Linen reads the crash report and the log next to it, then names the mod, the line and what to change. It’s free. A new item and a new block show the one registration each needs.