Package foundry.veil.platform.registry
Interface RegistrationProvider<T>
- Type Parameters:
T
- the operand 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(){}
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final RegistrationProvider.Factory
The singleton instance of theRegistrationProvider.Factory
. -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.core.Registry
<T> static <T> RegistrationProvider
<T> Gets a provider for specifiedmodId
andregistry
.static <T> RegistrationProvider
<T> get
(net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<T>> resourceKey, String modId) Gets a provider for specifiedmodId
andresourceKey
.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 specifiedmodId
andresourceKey
.- Type Parameters:
T
- the operand of the provider- Parameters:
resourceKey
- theResourceKey
of the registry of the providermodId
- the mod id that the provider will register objects for- Returns:
- the provider
-
get
Gets a provider for specifiedmodId
andregistry
.- Type Parameters:
T
- the operand of the provider- Parameters:
registry
- theRegistry
of 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
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 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
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
-