Skip to content

Fabric: register blocks/items eagerly and implement registerEntityDataSerializer via FabricEntityDataRegistry#1208

Open
Arilas wants to merge 2 commits into
DynamicTreesTeam:develop/26.1.2from
Arilas:fix/fabric-registration
Open

Fabric: register blocks/items eagerly and implement registerEntityDataSerializer via FabricEntityDataRegistry#1208
Arilas wants to merge 2 commits into
DynamicTreesTeam:develop/26.1.2from
Arilas:fix/fabric-registration

Conversation

@Arilas

@Arilas Arilas commented Jul 24, 2026

Copy link
Copy Markdown

Two Fabric registration bugs found while porting and running the Fabric build in a full (~90 mod) production client instance.

1. registerBlock / registerItem register lazily, so some entries never register

FabricRegistryLoader.registerBlock/registerItem return () -> Registry.register(...) — registration only happens when somebody first polls the supplier. Consequences observed at runtime:

  • Entries nobody polls during init (e.g. DTRegistries.DIRT_BUCKET) never make it into the registry 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 throw.
  • Polling the supplier twice would attempt a double registration.

Fixed by registering eagerly at call time and returning the captured instance, matching the other register* methods in the same class.

2. Missing registerEntityDataSerializer implementation — must go through FabricEntityDataRegistry

RegistryLoader declares registerEntityDataSerializer as abstract and the NeoForge loader implements it, but FabricRegistryLoader is missing the override entirely. Implementing it via vanilla's EntityDataSerializers.registerSerializer (the obvious route, and what we tried first) is rejected by Fabric API at runtime:

java.lang.IllegalStateException: Tried to register entity data serializer ... using EntityDataSerializers.registerSerializer.
This is not allowed as it can lead to desynchronization issues; use FabricEntityDataRegistry.register instead.

which fires on the first tree pack load (Species.generateSeedSeed.<init>) and takes down the whole mod init. This PR implements the override through FabricEntityDataRegistry.register(DynamicTrees.location(name), serializer).

Compile status (full transparency)

:fabric:compileJava on develop/26.1.2 currently fails at baseline with ~587 pre-existing errors (the module looks mid-port against the 26.1 toolchain — old renderer.v1 model API, Jade/Continuity compat, loot type classes, etc.). I verified with -Xmaxerrs raised 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

Arilas and others added 2 commits July 24, 2026 23:31
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant