Class FabricRegistryBuilder<T,R extends net.minecraft.util.registry.MutableRegistry<T>>

java.lang.Object
net.fabricmc.fabric.api.event.registry.FabricRegistryBuilder<T,R>
Type Parameters:
T - The type stored in the Registry
R - The registry type

public final class FabricRegistryBuilder<T,R extends net.minecraft.util.registry.MutableRegistry<T>> extends Object
Used to create custom registries, with specified registry attributes.
 
  SimpleRegistry<String> registry = FabricRegistryBuilder.createSimple(String.class, new Identifier("registry_sync", "fabric_registry"))
 													.attribute(RegistryAttribute.SYNCED)
 													.buildAndRegister();
 	
 
  • Method Details

    • from

      public static <T, R extends net.minecraft.util.registry.MutableRegistry<T>> FabricRegistryBuilder<T,R> from(R registry)
      Create a new FabricRegistryBuilder, the registry has the RegistryAttribute.MODDED attribute by default.
      Type Parameters:
      T - The type stored in the Registry
      R - The registry type
      Parameters:
      registry - The base registry type such as SimpleRegistry or DefaultedRegistry
      Returns:
      An instance of FabricRegistryBuilder
    • createSimple

      public static <T> FabricRegistryBuilder<T,net.minecraft.util.registry.SimpleRegistry<T>> createSimple(Class<T> type, net.minecraft.util.Identifier registryId)
      Create a new FabricRegistryBuilder using a SimpleRegistry, the registry has the RegistryAttribute.MODDED attribute by default.
      Type Parameters:
      T - The type stored in the Registry
      Parameters:
      registryId - The registry Identifier used as the registry id
      Returns:
      An instance of FabricRegistryBuilder
    • createDefaulted

      public static <T> FabricRegistryBuilder<T,net.minecraft.util.registry.DefaultedRegistry<T>> createDefaulted(Class<T> type, net.minecraft.util.Identifier registryId, net.minecraft.util.Identifier defaultId)
      Create a new FabricRegistryBuilder using a DefaultedRegistry, the registry has the RegistryAttribute.MODDED attribute by default.
      Type Parameters:
      T - The type stored in the Registry
      Parameters:
      registryId - The registry Identifier used as the registry id
      defaultId - The default registry id
      Returns:
      An instance of FabricRegistryBuilder
    • attribute

      public FabricRegistryBuilder<T,R> attribute(RegistryAttribute attribute)
      Add a RegistryAttribute to the registry.
      Parameters:
      attribute - the RegistryAttribute to add to the registry
      Returns:
      the instance of FabricRegistryBuilder
    • buildAndRegister

      public R buildAndRegister()
      Applies the attributes to the registry and registers it.
      Returns:
      the registry instance with the attributes applied