Interface RegistrationProvider<T>

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

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(){}
 
  • 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.
      It is recommended to store the resulted provider in a static final field to the factory creating multiple providers for the same resource key and mod id.
      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.
      It is recommended to store the resulted provider in a static final field to the factory creating multiple providers for the same resource key and mod id.
      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

      <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!
    • block

      default <I extends T> RegistryObject<I> block(String name, Function<net.minecraft.world.level.block.state.BlockBehaviour.Properties,? extends I> supplier)
    • block

      default <I extends T> RegistryObject<I> block(String name, Function<net.minecraft.world.level.block.state.BlockBehaviour.Properties,? extends I> supplier, net.minecraft.world.level.block.state.BlockBehaviour.Properties defaultProperties)
    • item

      default <I extends T> RegistryObject<I> item(String name, Function<net.minecraft.world.item.Item.Properties,? extends I> supplier)
    • item

      default <I extends T> RegistryObject<I> item(String name, Function<net.minecraft.world.item.Item.Properties,? extends I> supplier, net.minecraft.world.item.Item.Properties defaultProperties)
    • blockItem

      default <I extends T> RegistryObject<I> blockItem(String name, RegistryObject<net.minecraft.world.level.block.Block> block, UnaryOperator<net.minecraft.world.item.Item.Properties> supplier)
    • blockItem

      default <I extends T> RegistryObject<I> blockItem(String name, RegistryObject<net.minecraft.world.level.block.Block> block, UnaryOperator<net.minecraft.world.item.Item.Properties> supplier, net.minecraft.world.item.Item.Properties defaultProperties)
    • getEntries

      Collection<RegistryObject<T>> getEntries()
      Gets all the objects currently registered.
      Returns:
      an immutable view of all the objects currently registered
    • getModId

      String getModId()
      Gets the mod id that this provider registers objects for.
      Returns:
      the mod id
    • resourceKey

      net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<T>> resourceKey()