Class RegisterEvent

java.lang.Object
net.minecraftforge.eventbus.api.Event
net.minecraftforge.registries.RegisterEvent
All Implemented Interfaces:
IModBusEvent

public class RegisterEvent extends net.minecraftforge.eventbus.api.Event implements 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:
  • Field Details

    • registryKey

      @NotNull private final @NotNull ResourceKey<? extends Registry<?>> registryKey
    • forgeRegistry

      @Nullable final @Nullable ForgeRegistry<?> forgeRegistry
    • vanillaRegistry

      @Nullable private final @Nullable Registry<?> vanillaRegistry
  • Constructor Details

  • 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 to
      name - the name of the object to register as its key
      valueSupplier - 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

      @NotNull public @NotNull ResourceKey<? extends Registry<?>> getRegistryKey()
      Returns:
      The registry key linked to this event
    • getForgeRegistry

      @Nullable public <T> @Nullable IForgeRegistry<T> getForgeRegistry()
      Returns:
      The forge registry for the given registry key, or null if the registry is not a forge registry
    • getVanillaRegistry

      @Nullable public <T> @Nullable Registry<T> getVanillaRegistry()
      Returns:
      The vanilla registry for the given registry key, or null if the registry is not a vanilla registry
    • toString

      public String toString()
      Overrides:
      toString in class Object