Fabric API

Fabric API

152M Downloads

Resource Reloader v1 - SharedState Misses Some Tags on World Load

ekulxam opened this issue ยท 0 comments

commented

Mojmap warning
In 1.21.10 (FAPI 0.138.0+1.21.10), when using v1's SimpleResourceReloader, we are given the SharedState in the prepare method, which we can obtain lookups from. On regular resource reload, this is fine, but upon the first world load (see WorldLoader#load), our lookup is missing a lot of tags (using the item registry as an example).

HolderLookup.Provider delegate = store.get(ResourceLoader.RELOADER_REGISTRY_LOOKUP_KEY);
Image

This is because on first world load, all tags are actually stored in ReloadableServerResources's postponedTags, which I believe are only correctly put into future lookups after updateStaticRegistryTags is called.

To combat this, I've come up with a temporary solution in https://github.com/ekulxam/Spectre/compare/12b765b..9636dbc#diff-13a335527dba6451d26a52a1e4bf66f9f68ad85da68cdb2cf30d0261f297e0cbR80, where I've stored the List<PendingTags<?>> in the SharedState and then used it with the original lookup to create a special HolderLookup.Provider implementation.
Image
This implementation does correctly contain all tags (474 vs 16), but has the slight problem where the tags are actually not bound and the HolderSets have no contents. This does work to some extent though, as loading in #c:crops in a dynamic creative tab gives
Image

I'm mainly asking for a less cursed solution that actually has populated tags upon resource reload. Perhaps we could delay resource reloading to after updateStaticRegistryTags and see if the lookup is given with the correct tags.

This is arguably a minecraft bug, but I think Resource Reloader v1 has a good shot at fixing this.