Class EnumObjects<E extends Enum<E>,T>
java.lang.Object
org.moddingx.libx.registration.util.EnumObjects<E,T>
- Type Parameters:
E
- The type of the enum to use.T
- The type of the thing to register.
- All Implemented Interfaces:
Registerable
A
Registerable
that registers multiple objects, one for each value of an enum. This is
done via Registerable.registerAdditional(RegistrationContext, EntryCollector)
so
the enum names will be applied automatically.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.moddingx.libx.registration.Registerable
Registerable.EntryCollector, Registerable.TrackingCollector
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGets a value for an enum value.void
initTracking
(RegistrationContext ctx, Registerable.TrackingCollector builder) Adds fields with additional registry values to theRegistryTracker
.random
(net.minecraft.util.RandomSource random) Gets a random object from the objects in this EnumObjects.void
registerAdditional
(RegistrationContext ctx, Registerable.EntryCollector builder) Registers additional objects.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.moddingx.libx.registration.Registerable
registerClient, registerCommon
-
Constructor Details
-
EnumObjects
public EnumObjects(net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<T>> registryKey, Class<E> cls, Function<E, T> factory) Creates a new instance of EnumObjects.- Parameters:
registryKey
- The registry to register to.cls
- The class of the enum that is used. The enum must have at least one value.factory
- A factory function that creates the objects to be registered.
-
-
Method Details
-
get
Gets a value for an enum value. -
random
Gets a random object from the objects in this EnumObjects. -
registerAdditional
@OverridingMethodsMustInvokeSuper public void registerAdditional(RegistrationContext ctx, Registerable.EntryCollector builder) Description copied from interface:Registerable
Registers additional objects. Those may beRegisterable
as well. These objects will be registered with the id of this object and optionally a name suffix.- Specified by:
registerAdditional
in interfaceRegisterable
-
initTracking
@OverridingMethodsMustInvokeSuper public void initTracking(RegistrationContext ctx, Registerable.TrackingCollector builder) throws ReflectiveOperationException Description copied from interface:Registerable
Adds fields with additional registry values to theRegistryTracker
. This called, unlessRegistrationBuilder.disableRegistryTracking()
()} is set.- Specified by:
initTracking
in interfaceRegisterable
- Throws:
ReflectiveOperationException
-