Class RegisterEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.registries.RegisterEvent
- All Implemented Interfaces:
IModBusEvent
Fired for each registry when it is ready to have modded objects registered.
This event is fired for all builtin registries from vanilla (see
BuiltInRegistries
) and mods.
This event is fired on the mod-specific event bus, on both logical sides.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Registry
<?> private final ResourceKey
<? extends Registry<?>> -
Constructor Summary
ConstructorsConstructorDescriptionRegisterEvent
(ResourceKey<? extends Registry<?>> registryKey, Registry<?> registry) -
Method Summary
Modifier and TypeMethodDescriptionRegistry
<?> <T> @Nullable Registry
<T> getRegistry
(ResourceKey<? extends Registry<T>> key) ResourceKey
<? extends Registry<?>> <T> void
register
(ResourceKey<? extends Registry<T>> registryKey, Consumer<RegisterEvent.RegisterHelper<T>> consumer) Calls the provided consumer with a register helper if the provided registry key matches this event's registry key.<T> void
register
(ResourceKey<? extends Registry<T>> registryKey, ResourceLocation name, Supplier<T> valueSupplier) Registers the value with the given name to the stored registry if the provided registry key matches this event's registry key.
-
Field Details
-
registryKey
-
registry
-
-
Constructor Details
-
RegisterEvent
RegisterEvent(ResourceKey<? extends Registry<?>> registryKey, Registry<?> registry)
-
-
Method Details
-
register
public <T> void register(ResourceKey<? extends Registry<T>> registryKey, ResourceLocation name, Supplier<T> valueSupplier) Registers the value with the given name to the stored registry if the provided registry key matches this event's registry key.- Type Parameters:
T
- the type of the registry- Parameters:
registryKey
- the key of the registry to register the value toname
- the name of the object to register as its keyvalueSupplier
- a supplier of the object value- See Also:
-
register
public <T> void register(ResourceKey<? extends Registry<T>> registryKey, Consumer<RegisterEvent.RegisterHelper<T>> consumer) Calls the provided consumer with a register helper if the provided registry key matches this event's registry key.- Type Parameters:
T
- the type of the registry- Parameters:
registryKey
- the key of the registry to register objects to- See Also:
-
getRegistryKey
- Returns:
- The registry key linked to this event
-
getRegistry
- Returns:
- The registry linked to this event
-
getRegistry
- Parameters:
key
- the registry key to compare againgetRegistryKey()
- Returns:
- The registry typed to the given registry key if it matches
getRegistryKey()
, ornull
if it does not match.
-