Package net.minecraftforge.registries
Class RegisterEvent
java.lang.Object
net.minecraftforge.eventbus.api.Event
net.minecraftforge.registries.RegisterEvent
- All Implemented Interfaces:
IModBusEvent
This event fires for each forge and vanilla registry when all registries are ready to have modded objects registered.
Fired on the mod bus
.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraftforge.eventbus.api.Event
net.minecraftforge.eventbus.api.Event.HasResult, net.minecraftforge.eventbus.api.Event.Result
-
Field Summary
Modifier and TypeFieldDescription(package private) final @Nullable ForgeRegistry
<?> private final @NotNull ResourceKey
<? extends Registry<?>> private final @Nullable Registry
<?> -
Constructor Summary
ConstructorDescriptionRegisterEvent
(@NotNull ResourceKey<? extends Registry<?>> registryKey, @Nullable ForgeRegistry<?> forgeRegistry, @Nullable Registry<?> vanillaRegistry) -
Method Summary
Modifier and TypeMethodDescription<T> @Nullable IForgeRegistry
<T> @NotNull ResourceKey
<? extends Registry<?>> <T> @Nullable Registry
<T> <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.toString()
Methods inherited from class net.minecraftforge.eventbus.api.Event
getListenerList, getPhase, getResult, hasResult, isCancelable, isCanceled, setCanceled, setPhase, setResult
-
Field Details
-
registryKey
-
forgeRegistry
-
vanillaRegistry
-
-
Constructor Details
-
RegisterEvent
RegisterEvent(@NotNull @NotNull ResourceKey<? extends Registry<?>> registryKey, @Nullable @Nullable ForgeRegistry<?> forgeRegistry, @Nullable @Nullable Registry<?> vanillaRegistry)
-
-
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
-
getForgeRegistry
- Returns:
- The forge registry for the given registry key, or
null
if the registry is not a forge registry
-
getVanillaRegistry
- Returns:
- The vanilla registry for the given registry key, or
null
if the registry is not a vanilla registry
-
toString
-