-
-
Notifications
You must be signed in to change notification settings - Fork 71
Description
Description
When using DeferredRegister to register content in a custom registry added by another mod, initializing the register (eg. ACTIONS.register()) fails on Forge with the following error message (full crash report below). The same code works fine on Fabric.
java.lang.IllegalArgumentException: Registry ResourceKey[minecraft:root / hexcasting:action] does not exist!
This particular error message is for registering a value to Hex Casting's action registry. I ran the mod with a debugger, and it seems like my mod's initializer, where ACTIONS.register() is called, runs before Hex Casting's initializer, where the custom registry is added to BuiltInRegistries.REGISTRY. So, when Architectury attempts to look up the registry in ACTIONS.register(), the custom registry hasn't been added yet.
I was able to work around the issue by calling ACTIONS.register() in NewRegistryEvent, which fires after mod initialization but before RegisterEvent (docs). However, I'm not sure this is actually a good idea in general - I think it might fail if the mod adding the registry created it in NewRegistryEvent.
I guess a potential fix could be to defer actually looking up the registry until the corresponding RegisterEvent has been received?
Possibly related: #256
Example repo
I set up a minimal example based on the 1.20.1 Fabric/Forge Architectury template, attempting to register a value to Hex Casting's action registry.
Repository: object-Object/architectury-modded-registry-example (see also the workaround tag)
Relevant files:
- Common init: failing, workaround
- Forge init: failing, workaround
Logs
These logs are from running the forge:runClient Gradle task in the above repo, on the failing and workaround tags respectively.
- Failing:
- Workaround:
Versions
- Minecraft:
1.20.1 - Forge:
47.2.1 - Architectury:
- API:
9.1.12 - Plugin:
3.4.155 - Loom:
1.5.391
- API: