Interface TypedKey<T>

Type Parameters:
T - the type of the entry
All Superinterfaces:
Reference<T>

public sealed interface TypedKey<T> extends Reference<T>
A key bound to the registry it belongs to, so lookups are type-safe.

It is not a Key: use key() to get the plain key. Two typed keys are equal when they have the same registry and the same key.

Since:
0.1.0
  • Method Details

    • withRegistry

      static <T> TypedKey<T> withRegistry(RegistryKey<T> registry, Key key)
      Returns a key of the given registry.
      Type Parameters:
      T - the type of the entry
      Parameters:
      registry - the registry
      key - the key of the entry
      Returns:
      a key of the given registry
      Since:
      0.1.0
    • withRegistry

      static <T> TypedKey<T> withRegistry(RegistryKey<T> registry, @KeyPattern String key)
      Returns a key of the given registry.
      Type Parameters:
      T - the type of the entry
      Parameters:
      registry - the registry
      key - the key of the entry, for instance minecraft:stone
      Returns:
      a key of the given registry
      Since:
      0.1.0
    • registry

      RegistryKey<T> registry()
      Returns the registry the key belongs to.
      Returns:
      the registry the key belongs to
      Since:
      0.1.0
    • key

      Key key()
      Returns the plain key, without the registry.
      Returns:
      the plain key, without the registry
      Since:
      0.1.0