personthecat.catlib.event.registry.RegistryAddedEvent Maven / Gradle / Ivy
Show all versions of catlib-quilt Show documentation
package personthecat.catlib.event.registry;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.class_2378;
import net.minecraft.class_5321;
import net.minecraft.class_5455;
import org.jetbrains.annotations.ApiStatus;
import personthecat.catlib.event.LibEvent;
import personthecat.catlib.exception.MissingOverrideException;
import personthecat.catlib.exception.RegistryLookupException;
import personthecat.catlib.registry.RegistryHandle;
public class RegistryAddedEvent {
/**
* Exposes the currently-available {@link RegistryAddedEvent} for a registry of the given type.
* This event will fire any time an object is registered to this registry.
*
* Note that on the Forge platform, this event exposes a {@link RegistryHandle} which can
* either be a {@link class_2378 Mojang registry} or a Forge registry. The registry handle does
* allow new elements to be registered, which is guaranteed to succeed on the Forge platform
* due to when this event is fired.
*
*
Also note that the majority of objects in this registry have likely already been registered.
* For this reason, you may prefer to leverage the {@link #withRetroactive} method, which will
* fire immediately for each object already in the registry.
*
*
Finally, you should be aware that this event will fire for a single, builtin registry only.
* This means that dynamic registries will not be covered. If you wish to register additional
* callbacks to the dynamic registries, use {@link #withDynamic} instead.
*
* @throws RegistryLookupException If no registry is found.
* @param key The key of the registry which this event corresponds to.
* @param The type of object in the registry.
* @return A callback registrar for this registry.
*/
@ExpectPlatform
public static LibEvent> get(final class_5321> key) {
throw new MissingOverrideException();
}
/**
* This method registers a {@link RegistryAddedCallback} for a registry of the given type.
* Unlike {@link #get}, this method will also fire the callback for every object already
* contained within the registry.
*
* On the Forge platform, this means the registry will be forcibly unfrozen temporarily.
* Realistically speaking, this is a safe operation unless the Forge registry events have
* already fired. In that case, additional registry entries will simply have no effect.
*
*
Note that dynamic registries are not covered by this event.
*
* @throws RegistryLookupException If no registry is found.
* @param key The key of the registry which this event corresponds to.
* @param f The callback to fire in for every element in the registry.
* @param The type of object in the registry.
*/
@ExpectPlatform
public static void withRetroactive(final class_5321> key, final RegistryAddedCallback f) {
throw new MissingOverrideException();
}
/**
* This method registers a {@link RegistryAddedCallback} for a registry of the given type.
* Unlike {@link #get}, this method will also fire the callback for every object in a
* corresponding dynamic registry of the given type. It will fire every time the
* dynamic registries are loaded.
*
* Note that any objects already contained within the registry will not be covered by
* this event.
*
* @throws RegistryLookupException If no active registry is found.
* @throws IllegalStateException If a dynamic registry is not found on {@link RegistryAccessEvent}.
* @param key The key of the registry which this event corresponds to.
* @param f The callback to fire in for every element in the registry.
* @param The type of object in the registry.
*/
@ExpectPlatform
public static void withDynamic(final class_5321> key, final RegistryAddedCallback f) {
throw new MissingOverrideException();
}
/**
* This method registers a {@link RegistryAddedCallback} for a registry of the given type.
* Unlike {@link #get}, {@link #withRetroactive}, and {@link #withDynamic}, this callback
* will fire all objects already in the registry and all objects in the dynamic registries.
*
* @throws RegistryLookupException If no active registry is found.
* @throws IllegalStateException If a dynamic registry is not found on {@link RegistryAccessEvent}.
* @param key The key of the registry which this event corresponds to.
* @param f The callback to fire in for every element in the registry.
* @param The type of object in the registry.
*/
@ExpectPlatform
public static void exhaustive(final class_5321> key, final RegistryAddedCallback f) {
throw new MissingOverrideException();
}
/**
* Runs any platform-specific setup required on {@link RegistryAccessEvent}.
*
* @param access The dynamic registries after data packs are loaded.
*/
@ExpectPlatform
@ApiStatus.Internal
public static void onRegistryAccess(final class_5455 access) {
throw new MissingOverrideException();
}
}