Skip to content

Conversation

@LambdAurora
Copy link
Member

After some discussion on Discord, this PR aims to fix the headaches of using JsonDataLoader with Resource Loader v1.

This PR also introduce a new data store for results of a data resource reload as this was requested as well and it is true that currently there's no good way to store data in ways that respects its lifecycle.

There are some things I'm not yet sure in this design, notably with how to access such store using a MinecraftServer instance, right now a barebone DataResourceStore is interface injected onto it to have the least friction to gather data (think server.getOrThrow(DATA_KEY)), this should be safe in terms of injection as the method as a unique parameter to the resource loader (DataResourceStore.Key), the alternative would be to have a provider interface to inject and do server.getDataResourceStore().getOrThrow(DATA_KEY).

…and provide a mechanism to store data in `MinecraftServer` once a resource reload completes.
@LambdAurora LambdAurora added enhancement New feature or request tests PR has tests module: resource loader PRs and issues related to the resource loader API labels Oct 27, 2025
@LambdAurora LambdAurora requested a review from a team October 27, 2025 22:45
@modmuss50 modmuss50 added the priority: high High priority PRs that need review and work now. Review these first. label Oct 30, 2025
Copy link
Member

@modmuss50 modmuss50 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing stands out to me about the API, but get a review from someone who riased this issue in the first place. Something does look fishy about the injected interface tho.

@modmuss50 modmuss50 added the status: last call If you care, make yourself heard right away! label Nov 1, 2025
Copy link
Contributor

@Earthcomputer Earthcomputer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API looks good, it addresses my primary concern about not being able to use JsonDataLoader easily.


@SuppressWarnings("AddedMixinMembersNamePattern")
@Override
public <T> T getOrThrow(Key<T> key) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super generic method name mixined to MinecraftServer looks a little risky, but it's fine because we own the Key class.

*/
void registerReloader(
Identifier id,
Function<RegistryWrapper.WrapperLookup, ResourceReloader> factory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused why we are using a WrapperLookup here, rather than the DataResourceStore. Is there a good reason?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, the main need for this overload is for JsonDataLoader and it only needs WrapperLookup, I'm a bit concerned about how confusing the DataResourceStore might be here.
Also the DataResourceStore does not contain the WrapperLookup, the lookup and other reloaders are also available through the Vanilla ResourceReloader shared state store.

@modmuss50 modmuss50 added the status: merge me please Pull requests that are ready to merge label Nov 3, 2025
@modmuss50 modmuss50 merged commit d4d4122 into FabricMC:1.21.10 Nov 4, 2025
4 checks passed
modmuss50 pushed a commit that referenced this pull request Nov 4, 2025
…ide a store to store data reload results. (#4944)

* Allow once again to register data resource reloader using a factory, and provide a mechanism to store data in `MinecraftServer` once a resource reload completes.

* Remove dead code, add access to advancement and recipe loaders.

* Fix import order of `DataResourceLoader`.

* Fix interface injection of `DataResourceStore` into `MinecraftServer`.

(cherry picked from commit d4d4122)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request module: resource loader PRs and issues related to the resource loader API priority: high High priority PRs that need review and work now. Review these first. status: last call If you care, make yourself heard right away! status: merge me please Pull requests that are ready to merge tests PR has tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants