-
Notifications
You must be signed in to change notification settings - Fork 487
Allow registration of data resource reloader using a factory and provide a store to store data reload results. #4944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…and provide a mechanism to store data in `MinecraftServer` once a resource reload completes.
modmuss50
left a comment
There was a problem hiding this 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.
Earthcomputer
left a comment
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
…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)
After some discussion on Discord, this PR aims to fix the headaches of using
JsonDataLoaderwith 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
MinecraftServerinstance, right now a bareboneDataResourceStoreis interface injected onto it to have the least friction to gather data (thinkserver.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 doserver.getDataResourceStore().getOrThrow(DATA_KEY).