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(){}
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptiondefault <I extends T>
RegistryObject<I> block(String name, Function<net.minecraft.world.level.block.state.BlockBehaviour.Properties, ? extends I> supplier) 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) 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) 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) static <T> RegistrationProvider<T> Gets a provider for specifiedmodIdandregistry.static <T> RegistrationProvider<T> get(net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<T>> resourceKey, String modId) Gets a provider for specifiedmodIdandresourceKey.Gets all the objects currently registered.getModId()Gets the mod id that this provider registers objects for.default <I extends T>
RegistryObject<I> 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) <I extends T>
RegistryObject<I> Registers an object.net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<T>>
-
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 specifiedmodIdandresourceKey.
It is recommended to store the resulted provider in astatic finalfield to thefactorycreating multiple providers for the same resource key and mod id.- Type Parameters:
T- the type of the provider- Parameters:
resourceKey- theResourceKeyof the registry of the providermodId- the mod id that the provider will register objects for- Returns:
- the provider
-
get
Gets a provider for specifiedmodIdandregistry.
It is recommended to store the resulted provider in astatic finalfield to thefactorycreating multiple providers for the same resource key and mod id.- Type Parameters:
T- the type of the provider- Parameters:
registry- theRegistryof the providermodId- the mod id that the provider will register objects for- Returns:
- the provider
-
register
Registers an object.- Type Parameters:
I- the type of the object- Parameters:
name- the name of the objectsupplier- a supplier of the object to register- Returns:
- a wrapper containing the lazy registered object. Calling
gettoo 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()
-