Open object-Object opened 4 weeks ago
Update: I was also able to work around the issue by calling ACTIONS.register()
in the appropriate RegisterEvent
, but it's a bit annoying to implement since DeferredRegister.key
doesn't seem to be publicly accessible.
Actually, this doesn't seem to be working - the game runs without crashing, but the custom action isn't actually registered. Not sure why.
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.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 toBuiltInRegistries.REGISTRY
. So, when Architectury attempts to look up the registry inACTIONS.register()
, the custom registry hasn't been added yet.I was able to work around the issue by calling
ACTIONS.register()
inNewRegistryEvent
, which fires after mod initialization but beforeRegisterEvent
(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 inNewRegistryEvent
.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:
Logs
These logs are from running the
forge:runClient
Gradle task in the above repo, on the failing and workaround tags respectively.Versions
1.20.1
47.2.1
9.1.12
3.4.155
1.5.391