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

public abstract class SimpleResourceReloader<T> extends Object implements 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.

  • 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:
      reload in interface ResourceReloader
    • prepare

      protected abstract T prepare(ResourceReloader.Store store)
      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

      protected abstract void apply(T prepared, ResourceReloader.Store store)
      Synchronously applies prepared data to the game state.
      Parameters:
      prepared - the prepared data
      store - the data store used for sharing state between resource reloaders