Class SimpleResourceReloader<T>

java.lang.Object
net.fabricmc.fabric.api.resource.v1.reloader.SimpleResourceReloader<T>
Type Parameters:
T - the data object
All Implemented Interfaces:
net.minecraft.server.packs.resources.PreparableReloadListener

public abstract class SimpleResourceReloader<T> extends Object implements net.minecraft.server.packs.resources.PreparableReloadListener
A variant of SimplePreparableReloadListener 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 ResourceManagerReloadListener.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface net.minecraft.server.packs.resources.PreparableReloadListener

    net.minecraft.server.packs.resources.PreparableReloadListener.PreparationBarrier, net.minecraft.server.packs.resources.PreparableReloadListener.SharedState, net.minecraft.server.packs.resources.PreparableReloadListener.StateKey<T>
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    apply(T prepared, net.minecraft.server.packs.resources.PreparableReloadListener.SharedState store)
    Synchronously applies prepared data to the game state.
    protected abstract T
    prepare(net.minecraft.server.packs.resources.PreparableReloadListener.SharedState store)
    Asynchronously processes and prepares resource-based data.
    reload(net.minecraft.server.packs.resources.PreparableReloadListener.SharedState store, Executor prepareExecutor, net.minecraft.server.packs.resources.PreparableReloadListener.PreparationBarrier reloadSynchronizer, Executor applyExecutor)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.minecraft.server.packs.resources.PreparableReloadListener

    getName, prepareSharedState
  • Constructor Details

    • SimpleResourceReloader

      public SimpleResourceReloader()
  • Method Details

    • reload

      public final CompletableFuture<Void> reload(net.minecraft.server.packs.resources.PreparableReloadListener.SharedState store, Executor prepareExecutor, net.minecraft.server.packs.resources.PreparableReloadListener.PreparationBarrier reloadSynchronizer, Executor applyExecutor)
      Specified by:
      reload in interface net.minecraft.server.packs.resources.PreparableReloadListener
    • prepare

      protected abstract T prepare(net.minecraft.server.packs.resources.PreparableReloadListener.SharedState 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, net.minecraft.server.packs.resources.PreparableReloadListener.SharedState 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