Reload Listeners

The ReloadListenerRegistry class allows developers to register PreparableReloadListeners for different PackTypes.

Methods

register(PackType, PreparableReloadListener)

This method registers a `PreparableReloadListener` for the specified `PackType`. This method is not recommended since the identifier for your listener is randomly generated by Architectury, and may be hard for other mods to declare dependency on your listener.

Parameters:

  • type - the PackType for which the listener should be registered.
  • listener - the PreparableReloadListener to register.

register(PackType, PreparableReloadListener, ResourceLocation)

This method registers a PreparableReloadListener for the specified PackType and associates it with the specified listenerId.

Parameters:

  • type - the PackType for which the listener should be registered.
  • listener - the PreparableReloadListener to register.
  • listenerId - the ResourceLocation to associate with the listener.

register(PackType, PreparableReloadListener, ResourceLocation, Collection<ResourceLocation>)

This method registers a PreparableReloadListener for the specified PackType, associates it with the specified listenerId, and specifies the dependencies of the listener.

Note: The dependencies sorting only functions on Fabric or Quilt.

Parameters:

  • type - the PackType for which the listener should be registered.
  • listener - the PreparableReloadListener to register.
  • listenerId - the ResourceLocation to associate with the listener.
  • dependencies - a collection of ResourceLocation objects that represent the dependencies of the listener.

Example

Here's an example of how to use the ReloadListenerRegistry class to register a PreparableReloadListener for the CLIENT_RESOURCES PackType:

public class MyReloadListener implements PreparableReloadListener {
    // implementation of PreparableReloadListener methods
}
 
// register the listener
ReloadListenerRegistry.register(PackType.CLIENT_RESOURCES, new MyReloadListener());