Interface RegistrationProvider<T>

Type Parameters:
T - the type of the objects that this class registers

@Internal public interface RegistrationProvider<T>
Utility class for multiloader registration.

Example usage:


 public static final RegistrationProvider<Test> PROVIDER = RegistrationProvider.get(Test.REGISTRY, "modid");
 public static final RegistryObject<Test> OBJECT = PROVIDER.register("object", () -> new Test());

 // The purpose of this method is to be called in the mod's constructor, in order to assure that the class is loaded, and that objects can be registered.
 public static void loadClass(){}
 
  • Field Details

  • Method Details

    • get

      static <T> RegistrationProvider<T> get(net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<T>> resourceKey, String modId)
      Gets a provider for specified modId and resourceKey.
      Type Parameters:
      T - the type of the provider
      Parameters:
      resourceKey - the ResourceKey of the registry of the provider
      modId - the mod id that the provider will register objects for
      Returns:
      the provider
    • get

      static <T> RegistrationProvider<T> get(net.minecraft.core.Registry<T> registry, String modId)
      Gets a provider for specified modId and registry.
      Type Parameters:
      T - the type of the provider
      Parameters:
      registry - the Registry of the provider
      modId - the mod id that the provider will register objects for
      Returns:
      the provider
    • register

      default <I extends T> RegistryObject<I> register(String name, Supplier<? extends I> supplier)
      Registers an object.
      Type Parameters:
      I - the type of the object
      Parameters:
      name - the name of the object
      supplier - a supplier of the object to register
      Returns:
      a wrapper containing the lazy registered object. Calling get too early on the wrapper might result in crashes!
    • register

      <I extends T> RegistryObject<I> register(net.minecraft.resources.ResourceLocation id, Supplier<? extends I> supplier)
      Registers an object.
      Type Parameters:
      I - the type of the object
      Parameters:
      id - the id of the object
      supplier - a supplier of the object to register
      Returns:
      a wrapper containing the lazy registered object. Calling get too early on the wrapper might result in crashes!
    • getEntries

      Collection<RegistryObject<T>> getEntries()
      Returns:
      An immutable view of all the objects currently registered
    • asVanillaRegistry

      net.minecraft.core.Registry<T> asVanillaRegistry()
      Returns:
      A wrapper of the underlying registry this provider registers into
    • getModId

      String getModId()
      Returns:
      The mod id this provider registers objects for