Repository navigation
Explain frozen-registry writes from Fabric mods - #2321
Closed
1499501762 wants to merge 1 commit into
Closed
1499501762 wants to merge 1 commit into
1499501762 wants to merge 1 commit into
Conversation
fabric-registry-sync redirects BuiltInRegistries.bootStrap() inside Bootstrap to createContents() and calls the real bootstrap again from Main, so the registry freeze only happens after mod initializers have run. NeoForge keeps the vanilla order and freezes during bootstrap, i.e. before mods are constructed. A Fabric mod that registers from a BuiltInRegistries.freeze() hook, or from a late mod-init path, therefore fails with "Registry is already frozen" and gets a stack trace that says nothing about why it works on Fabric. This only adds a log line naming the mod, the key and the registry, plus the supported alternatives. Nothing is cancelled, deferred or relaxed - the exception is still thrown exactly as before. Attribution uses the namespace of the key being registered, which is the mod id for essentially every Fabric mod. Resolving the calling class instead would need a class load or a stack walk, and an entry point can register on behalf of another mod anyway.
|
but... why? |
Member
|
This is not necessary, and also the whole PR looks AI generated.
:D |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Adds a log line when a Fabric mod writes into a registry that NeoForge already froze, naming the mod, the key and the registry, and pointing at the supported alternatives. Nothing else changes - the exception is still thrown exactly as before, no write is relaxed or deferred.
Why
fabric-registry-syncredirectsBuiltInRegistries.bootStrap()insideBootstraptocreateContents()and calls the real bootstrap again fromMain, so the freeze happens after mod initializers have run. NeoForge keeps the vanilla order and freezes during bootstrap, i.e. before mods are constructed. A Fabric mod that registers from aBuiltInRegistries.freeze()hook therefore fails with:and all the user sees is that line plus a stack in which Connector does not appear at all - which makes it look like an injection problem at first.
Concrete trail, from Create Fly: its own
onInitializehook skipsCreate.register()wheneverfabric-apiis present, so on Connector the@At("TAIL")hook becomes the first touch of the registry class and the write lands on an already frozen registry. The same jar starts fine on Fabric (Done (0.223s)!), so this is an ordering difference rather than a broken mixin.Verification
The Fabric mod 'create' is registering 'create:arm_interaction_point_type' into 'minecraft:root' after that registry was frozen.- andMixin apply for modfailures stay at 0.Done, no injection errors.Caveat: I could not run the Gradle build in my environment (
forgified-fabric-loader:2.5.85+0.19.3+26.1.2is not resolvable outside the local publish chain), so I verified by compiling this mixin against the currentconnector.jarand injecting it plus the mixins.json entry into a copy of that jar. The source change itself is these two files, and the injector resolves againstMappedRegistry.validateWrite(ResourceKey).Not part of this PR
This does not make Create Fly start. With the registry ordering worked around it then fails on
A non-vanilla reload listener ... was added via mixin before the AddReloadListenerEvent. That is the reason this PR only improves the diagnostic instead of relaxingMappedRegistry.validateWriteglobally - the shim would carry a large blast radius for no user-visible gain here.