Interface SimpleResourceReloadListener<T>

Type Parameters:
T - The data object.
All Superinterfaces:
IdentifiableResourceReloadListener, net.minecraft.resource.ResourceReloadListener

public interface SimpleResourceReloadListener<T>
extends IdentifiableResourceReloadListener
A simplified version of the "resource reload listener" interface, hiding the peculiarities of the API.

In essence, there are two stages:

  • load: 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 load 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 SynchronousResourceReloadListener in conjunction with IdentifiableResourceReloadListener.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface net.minecraft.resource.ResourceReloadListener

    net.minecraft.resource.ResourceReloadListener.Synchronizer
  • Method Summary

    Modifier and Type Method Description
    CompletableFuture<Void> apply​(T data, net.minecraft.resource.ResourceManager manager, net.minecraft.util.profiler.Profiler profiler, Executor executor)
    Synchronously apply loaded data to the game state.
    CompletableFuture<T> load​(net.minecraft.resource.ResourceManager manager, net.minecraft.util.profiler.Profiler profiler, Executor executor)
    Asynchronously process and load resource-based data.
    default CompletableFuture<Void> reload​(net.minecraft.resource.ResourceReloadListener.Synchronizer helper, net.minecraft.resource.ResourceManager manager, net.minecraft.util.profiler.Profiler loadProfiler, net.minecraft.util.profiler.Profiler applyProfiler, Executor loadExecutor, Executor applyExecutor)  

    Methods inherited from interface net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener

    getFabricDependencies, getFabricId

    Methods inherited from interface net.minecraft.resource.ResourceReloadListener

    getName
  • Method Details

    • reload

      default CompletableFuture<Void> reload​(net.minecraft.resource.ResourceReloadListener.Synchronizer helper, net.minecraft.resource.ResourceManager manager, net.minecraft.util.profiler.Profiler loadProfiler, net.minecraft.util.profiler.Profiler applyProfiler, Executor loadExecutor, Executor applyExecutor)
      Specified by:
      reload in interface net.minecraft.resource.ResourceReloadListener
    • load

      CompletableFuture<T> load​(net.minecraft.resource.ResourceManager manager, net.minecraft.util.profiler.Profiler profiler, Executor executor)
      Asynchronously process and load resource-based data. The code must be thread-safe and not modify game state!
      Parameters:
      manager - The resource manager used during reloading.
      profiler - The profiler which may be used for this stage.
      executor - The executor which should be used for this stage.
      Returns:
      A CompletableFuture representing the "data loading" stage.
    • apply

      CompletableFuture<Void> apply​(T data, net.minecraft.resource.ResourceManager manager, net.minecraft.util.profiler.Profiler profiler, Executor executor)
      Synchronously apply loaded data to the game state.
      Parameters:
      manager - The resource manager used during reloading.
      profiler - The profiler which may be used for this stage.
      executor - The executor which should be used for this stage.
      Returns:
      A CompletableFuture representing the "data applying" stage.