Class FabricRegistryBuilder<T,R extends MutableRegistry<T>>
java.lang.Object
net.fabricmc.fabric.api.event.registry.FabricRegistryBuilder<T,R>
- Type Parameters:
T- The type stored in the RegistryR- The registry type
Used to create custom registries, with specified registry attributes.
See the following example for creating a Registry of String objects.
RegistryKey<Registry<String>> registryKey = RegistryKey.ofRegistry(new Identifier("modid", "registry_name"));
Registry<String> registry = FabricRegistryBuilder.createSimple(registryKey)
.attribute(RegistryAttribute.SYNCED)
.buildAndRegister();
-
Method Summary
Modifier and TypeMethodDescriptionattribute(RegistryAttribute attribute) Add aRegistryAttributeto the registry.Applies the attributes to the registry and registers it.static <T> FabricRegistryBuilder<T,SimpleDefaultedRegistry<T>> createDefaulted(Class<T> type, Identifier registryId, Identifier defaultId) Deprecated.static <T> FabricRegistryBuilder<T,SimpleDefaultedRegistry<T>> createDefaulted(RegistryKey<Registry<T>> registryKey, Identifier defaultId) Create a newFabricRegistryBuilderusing aDefaultedRegistry, the registry has theRegistryAttribute.MODDEDattribute by default.static <T> FabricRegistryBuilder<T,SimpleRegistry<T>> createSimple(Class<T> type, Identifier registryId) Deprecated.Please migrate tocreateSimple(RegistryKey)static <T> FabricRegistryBuilder<T,SimpleRegistry<T>> createSimple(RegistryKey<Registry<T>> registryKey) Create a newFabricRegistryBuilderusing aSimpleRegistry, the registry has theRegistryAttribute.MODDEDattribute by default.static <T,R extends MutableRegistry<T>>
FabricRegistryBuilder<T,R> from(R registry) Create a newFabricRegistryBuilder, the registry has theRegistryAttribute.MODDEDattribute by default.
-
Method Details
-
from
Create a newFabricRegistryBuilder, the registry has theRegistryAttribute.MODDEDattribute by default.- Type Parameters:
T- The type stored in the RegistryR- The registry type- Parameters:
registry- The base registry type such asSimpleRegistryorDefaultedRegistry- Returns:
- An instance of FabricRegistryBuilder
-
createSimple
public static <T> FabricRegistryBuilder<T,SimpleRegistry<T>> createSimple(RegistryKey<Registry<T>> registryKey) Create a newFabricRegistryBuilderusing aSimpleRegistry, the registry has theRegistryAttribute.MODDEDattribute by default.- Type Parameters:
T- The type stored in the Registry- Parameters:
registryKey- The registryRegistryKey- Returns:
- An instance of FabricRegistryBuilder
-
createDefaulted
public static <T> FabricRegistryBuilder<T,SimpleDefaultedRegistry<T>> createDefaulted(RegistryKey<Registry<T>> registryKey, Identifier defaultId) Create a newFabricRegistryBuilderusing aDefaultedRegistry, the registry has theRegistryAttribute.MODDEDattribute by default.- Type Parameters:
T- The type stored in the Registry- Parameters:
registryKey- The registryRegistryKeydefaultId- The default registry id- Returns:
- An instance of FabricRegistryBuilder
-
createSimple
@Deprecated public static <T> FabricRegistryBuilder<T,SimpleRegistry<T>> createSimple(Class<T> type, Identifier registryId) Deprecated.Please migrate tocreateSimple(RegistryKey)Create a newFabricRegistryBuilderusing aSimpleRegistry, the registry has theRegistryAttribute.MODDEDattribute by default.- Type Parameters:
T- The type stored in the Registry- Parameters:
registryId- The registryIdentifierused as the registry id- Returns:
- An instance of FabricRegistryBuilder
-
createDefaulted
@Deprecated public static <T> FabricRegistryBuilder<T,SimpleDefaultedRegistry<T>> createDefaulted(Class<T> type, Identifier registryId, Identifier defaultId) Deprecated.Please migrate tocreateDefaulted(RegistryKey, Identifier)Create a newFabricRegistryBuilderusing aDefaultedRegistry, the registry has theRegistryAttribute.MODDEDattribute by default.- Type Parameters:
T- The type stored in the Registry- Parameters:
registryId- The registryIdentifierused as the registry iddefaultId- The default registry id- Returns:
- An instance of FabricRegistryBuilder
-
attribute
Add aRegistryAttributeto the registry.- Parameters:
attribute- theRegistryAttributeto add to the registry- Returns:
- the instance of
FabricRegistryBuilder
-
buildAndRegister
Applies the attributes to the registry and registers it.- Returns:
- the registry instance with the attributes applied
-
createDefaulted(RegistryKey, Identifier)