Package net.neoforged.neoforge.event
Class SortedReloadListenerEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.SortedReloadListenerEvent
- Direct Known Subclasses:
AddClientReloadListenersEvent,AddServerReloadListenersEvent
public abstract class SortedReloadListenerEvent
extends net.neoforged.bus.api.Event
Base class for
AddServerReloadListenersEvent and AddClientReloadListenersEvent.
This class holds the sorting logic that allows for the creation of dependency ordering.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final MutableGraph<PreparableReloadListener> private final Map<PreparableReloadListener, ResourceLocation> private final PreparableReloadListenerprivate final Map<ResourceLocation, PreparableReloadListener> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSortedReloadListenerEvent(List<PreparableReloadListener> vanillaListeners, SortedReloadListenerEvent.NameLookup lookup) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDependency(ResourceLocation first, ResourceLocation second) Adds a new dependency entry, such thatfirstmust run beforesecond.voidaddListener(ResourceLocation key, PreparableReloadListener listener) Adds a newreload listenerto the resource manager.getGraph()Returns an immutable view of the dependency graph.Returns a reference to the last vanilla listener, used during the final sort.Returns aSortedReloadListenerEvent.NameLookupfor all reload listeners known by this event.private PreparableReloadListenerprivate ResourceLocationgetOrThrow(PreparableReloadListener listener) Returns an immutable view of the reload listener registry.
-
Field Details
-
registry
-
keys
-
graph
-
lastVanilla
-
-
Constructor Details
-
SortedReloadListenerEvent
@Internal protected SortedReloadListenerEvent(List<PreparableReloadListener> vanillaListeners, SortedReloadListenerEvent.NameLookup lookup)
-
-
Method Details
-
addListener
Adds a newreload listenerto the resource manager.Unless explicitly specified, this listener will run after all vanilla listeners, in the order it was registered.
- Parameters:
key- The resource location that identifies the reload listener for dependency sorting.listener- The listener to add.- Throws:
IllegalArgumentException- if another listener with that key was already registered.
-
addDependency
Adds a new dependency entry, such thatfirstmust run beforesecond.Introduction of dependency cycles (first->second->first) will cause an error when the event is finished.
- Parameters:
first- The key of the reload listener that must run first.second- The key of the reload listener that must run afterfirst.- Throws:
IllegalArgumentException- if eitherfirstorsecondhas not been registered viaaddListener(net.minecraft.resources.ResourceLocation, net.minecraft.server.packs.resources.PreparableReloadListener).
-
getGraph
Returns an immutable view of the dependency graph. -
getRegistry
Returns an immutable view of the reload listener registry.The registry is linked, meaning the iteration order depends on the registration order.
-
getNameLookup
Returns aSortedReloadListenerEvent.NameLookupfor all reload listeners known by this event. -
getLastVanillaListener
Returns a reference to the last vanilla listener, used during the final sort. -
getOrThrow
-
getOrThrow
-