Class SimpleResourceReloader<T>
java.lang.Object
net.fabricmc.fabric.api.resource.v1.reloader.SimpleResourceReloader<T>
- Type Parameters:
T- the data object
- All Implemented Interfaces:
ResourceReloader
A variant of
SinglePreparationResourceReloader
which passes the shared state store instead of the resource manager in its methods.
In essence, there are two stages:
- prepare: create an instance of your data object containing all loaded and processed information,
- apply: apply the information from the data object to the game instance.
The prepare stage should be self-contained as it can run on any thread! However, the apply stage is guaranteed to run on the game thread.
For a fully synchronous alternative, consider using
SynchronousResourceReloader.
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.minecraft.resource.ResourceReloader
ResourceReloader.Key<T>, ResourceReloader.Store, ResourceReloader.Synchronizer -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidapply(T prepared, ResourceReloader.Store store) Synchronously applies prepared data to the game state.protected abstract Tprepare(ResourceReloader.Store store) Asynchronously processes and prepares resource-based data.final CompletableFuture<Void> reload(ResourceReloader.Store store, Executor prepareExecutor, ResourceReloader.Synchronizer reloadSynchronizer, Executor applyExecutor) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.resource.ResourceReloader
getName, prepareSharedState
-
Constructor Details
-
SimpleResourceReloader
public SimpleResourceReloader()
-
-
Method Details
-
reload
public final CompletableFuture<Void> reload(ResourceReloader.Store store, Executor prepareExecutor, ResourceReloader.Synchronizer reloadSynchronizer, Executor applyExecutor) - Specified by:
reloadin interfaceResourceReloader
-
prepare
Asynchronously processes and prepares resource-based data. The code must be thread-safe and not modify game state!- Parameters:
store- the data store used for sharing state between resource reloaders- Returns:
- the prepared data
-
apply
Synchronously applies prepared data to the game state.- Parameters:
prepared- the prepared datastore- the data store used for sharing state between resource reloaders
-