Package foundry.veil.platform.registry
Interface RegistrationProvider<T>
- Type Parameters:
T- the operand 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 -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final RegistrationProvider.FactoryThe singleton instance of theRegistrationProvider.Factory. -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.core.Registry<T> 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.getModId()default <I extends T>
RegistryObject<I> Registers an object.<I extends T>
RegistryObject<I> Registers an object.
-
Field Details
-
FACTORY
The singleton instance of theRegistrationProvider.Factory. This is different on each loader.
-
-
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.- Type Parameters:
T- the operand 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.- Type Parameters:
T- the operand 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 operand 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!
-
register
<I extends T> RegistryObject<I> register(net.minecraft.resources.ResourceLocation id, Supplier<? extends I> supplier) Registers an object.- Type Parameters:
I- the operand of the object- Parameters:
id- the id 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!
-
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
-