Class FabricRegistryBuilder<T, R extends net.minecraft.core.WritableRegistry<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
public final class FabricRegistryBuilder<T, R extends net.minecraft.core.WritableRegistry<T>>
extends Object
Used to create custom registries, with specified registry attributes.
See the following example for creating a Registry of String objects.
ResourceKey<Registry<String>> key = ResourceKey.createRegistryKey(Identifier.fromNamespaceAndPath("modid", "custom_registry"));
Registry<String> registry = FabricRegistryBuilder.createSimple(key)
.attribute(RegistryAttribute.SYNCED)
.buildAndRegister();
Tags for the entries of a custom registry must be placed in
/tags/<registry namespace>/<registry path>/. For example, the tags for the example
registry above would be placed in /tags/modid/registry_name/.
-
Method Summary
Modifier and TypeMethodDescriptionattribute(RegistryAttribute attribute) Add aRegistryAttributeto the registry.Applies the attributes to the registry and registers it.static <T> FabricRegistryBuilder<T, net.minecraft.core.MappedRegistry<T>> Deprecated.static <T> FabricRegistryBuilder<T, net.minecraft.core.MappedRegistry<T>> create(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> key) Create a newFabricRegistryBuilderusing aMappedRegistry, the registry has theRegistryAttribute.MODDEDattribute by default.static <T> FabricRegistryBuilder<T, net.minecraft.core.DefaultedMappedRegistry<T>> createDefaulted(Class<T> type, net.minecraft.resources.Identifier registryId, net.minecraft.resources.Identifier defaultId) Deprecated.Please migrate tocreateDefaulted(ResourceKey, Identifier)static <T> FabricRegistryBuilder<T, net.minecraft.core.DefaultedMappedRegistry<T>> createDefaulted(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> key, net.minecraft.resources.Identifier defaultId) Create a newFabricRegistryBuilderusing aDefaultedRegistry, the registry has theRegistryAttribute.MODDEDattribute by default.static <T, R extends net.minecraft.core.WritableRegistry<T>>
FabricRegistryBuilder<T, R> from(R registry) Create a newFabricRegistryBuilder, the registry has theRegistryAttribute.MODDEDattribute by default.
-
Method Details
-
from
public static <T, R extends net.minecraft.core.WritableRegistry<T>> FabricRegistryBuilder<T,R> from(R registry) 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 asMappedRegistryorDefaultedRegistry- Returns:
- An instance of FabricRegistryBuilder
-
create
public static <T> FabricRegistryBuilder<T, net.minecraft.core.MappedRegistry<T>> create(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> key) Create a newFabricRegistryBuilderusing aMappedRegistry, the registry has theRegistryAttribute.MODDEDattribute by default.- Type Parameters:
T- The type stored in the Registry- Parameters:
key- The registry'sResourceKey- Returns:
- An instance of FabricRegistryBuilder
-
createDefaulted
public static <T> FabricRegistryBuilder<T, net.minecraft.core.DefaultedMappedRegistry<T>> createDefaulted(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> key, net.minecraft.resources.Identifier defaultId) Create a newFabricRegistryBuilderusing aDefaultedRegistry, the registry has theRegistryAttribute.MODDEDattribute by default.- Type Parameters:
T- The type stored in the Registry- Parameters:
key- The registry'sResourceKeydefaultId- The default registry id- Returns:
- An instance of FabricRegistryBuilder
-
create
@Deprecated public static <T> FabricRegistryBuilder<T, net.minecraft.core.MappedRegistry<T>> create(Class<T> type, net.minecraft.resources.Identifier registryId) Deprecated.Please migrate tocreate(ResourceKey)Create a newFabricRegistryBuilderusing aMappedRegistry, 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, net.minecraft.core.DefaultedMappedRegistry<T>> createDefaulted(Class<T> type, net.minecraft.resources.Identifier registryId, net.minecraft.resources.Identifier defaultId) Deprecated.Please migrate tocreateDefaulted(ResourceKey, 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
-
create(ResourceKey)