Class RegistryKey<T>

java.lang.Object
net.minecraft.util.registry.RegistryKey<T>
Type Parameters:
T - the type of the value

public class RegistryKey<T>
extends Object
Represents a key for a value in a registry in a context where a root registry is available.
See Also:
Registry.ROOT
  • Field Details

  • Constructor Details

  • Method Details

    • of

      public static <T> RegistryKey<T> of​(RegistryKey<Registry<T>> registry, Identifier value)
      Creates a registry key for a value in a registry with a registry key for the value-holding registry in the root registry and an identifier of the value.

      You can call it like RegistryKey.of(Registry.ITEM_KEY, new Identifier("iron_ingot")) to create a registry key for iron ingot.

      Type Parameters:
      T - the type of the value
      Parameters:
      registry - the registry key of the registry in the root registry
      value - the identifier of the value
    • ofRegistry

      public static <T> RegistryKey<Registry<T>> ofRegistry​(Identifier registry)
      Creates a registry key for a registry in the root registry (registry of all registries) with an identifier for the registry.

      You can call it like RegistryKey.of(new Identifier("block")) to create a registry key for the block registry.

      Type Parameters:
      T - the element type of the registry
      Parameters:
      registry - the identifier of the registry
    • of

      private static <T> RegistryKey<T> of​(Identifier registry, Identifier value)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getValue

      public Identifier getValue()
    • createKeyFactory

      public static <T> Function<Identifier,​RegistryKey<T>> createKeyFactory​(RegistryKey<Registry<T>> registry)
      Creates a function that converts an identifier to a registry key for the registry that registry refers to in the root registry.
      Parameters:
      registry - the reference to the value-holding registry in the root registry