Fabric: register blocks/items eagerly and implement registerEntityDataSerializer via FabricEntityDataRegistry#1208
Open
Arilas wants to merge 2 commits into
Open
Conversation
registerBlock/registerItem returned lazy suppliers that only perform the Registry.register call when first polled. Entries nobody polls during init (e.g. DTRegistries.DIRT_BUCKET) never get registered at all - the dirt bucket crafting recipe then fails to load with "Unknown registry key ... dynamictrees:dirt_bucket". A first poll after init would hit a frozen registry, and polling twice would attempt a double registration. Register eagerly at call time and return the captured instance, matching the other register* methods in this class. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…Registry RegistryLoader declares registerEntityDataSerializer as abstract (the NeoForge loader implements it) but the Fabric loader was missing the override entirely. Implement it through Fabric API's FabricEntityDataRegistry. Note that registering through vanilla's EntityDataSerializers.registerSerializer is not an option: Fabric API rejects it at runtime with "IllegalStateException: Tried to register entity data serializer ... This is not allowed as it can lead to desynchronization issues; use FabricEntityDataRegistry.register instead", which fires on the first tree pack load (Species.generateSeed -> Seed.<init>) and takes down mod init. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Two Fabric registration bugs found while porting and running the Fabric build in a full (~90 mod) production client instance.
1.
registerBlock/registerItemregister lazily, so some entries never registerFabricRegistryLoader.registerBlock/registerItemreturn() -> Registry.register(...)— registration only happens when somebody first polls the supplier. Consequences observed at runtime:DTRegistries.DIRT_BUCKET) never make it into the registry at all — the dirt bucket crafting recipe then fails to load withUnknown registry key ... dynamictrees:dirt_bucket.Fixed by registering eagerly at call time and returning the captured instance, matching the other
register*methods in the same class.2. Missing
registerEntityDataSerializerimplementation — must go throughFabricEntityDataRegistryRegistryLoaderdeclaresregisterEntityDataSerializeras abstract and the NeoForge loader implements it, butFabricRegistryLoaderis missing the override entirely. Implementing it via vanilla'sEntityDataSerializers.registerSerializer(the obvious route, and what we tried first) is rejected by Fabric API at runtime:which fires on the first tree pack load (
Species.generateSeed→Seed.<init>) and takes down the whole mod init. This PR implements the override throughFabricEntityDataRegistry.register(DynamicTrees.location(name), serializer).Compile status (full transparency)
:fabric:compileJavaondevelop/26.1.2currently fails at baseline with ~587 pre-existing errors (the module looks mid-port against the 26.1 toolchain — oldrenderer.v1model API, Jade/Continuity compat, loot type classes, etc.). I verified with-Xmaxerrsraised that the error set is unchanged by this patch and that none of the reported errors involve the lines added or modified here; both fixes are the exact change we run (and have validated at runtime) in our ported Fabric build.🤖 Generated with Claude Code