Class GameRegistryAdapter<V>

java.lang.Object
net.darkhax.bookshelf.common.api.registry.adapters.GameRegistryAdapter<V>
Type Parameters:
V - The type of value held by the registry.
All Implemented Interfaces:
RegistryAdapter<net.minecraft.resources.ResourceKey<V>, V>
Direct Known Subclasses:
BlockRegistryAdapter, CreativeModeTabAdapter, ItemRegistryAdapter, PotPatternAdapter, RecipeTypeAdapter, SoundEventAdapter

public class GameRegistryAdapter<V> extends Object implements RegistryAdapter<net.minecraft.resources.ResourceKey<V>, V>
A basic registry adapter that can register into most vanilla style registries.
  • Field Details

    • context

      protected final RegistrationContext context
      Context that is shared by all registry adapters owned by the same namespace.
    • registryKey

      protected final net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<V>> registryKey
      The id of the registry being adapted.
    • registryFunc

      protected final BiConsumer<net.minecraft.resources.ResourceKey<V>, Supplier<V>> registryFunc
      A function that accepts and registers a key and value supplier.
  • Constructor Details

    • GameRegistryAdapter

      public GameRegistryAdapter(RegistrationContext context, net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<V>> registryKey, BiConsumer<net.minecraft.resources.ResourceKey<V>, Supplier<V>> registryFunc)
  • Method Details

    • add

      public RegistryReference<net.minecraft.resources.ResourceKey<V>, V> add(String key, Supplier<V> value)
      Description copied from interface: RegistryAdapter
      Adds a value to the registry. Values are not necessarily registered immediately.
      Specified by:
      add in interface RegistryAdapter<net.minecraft.resources.ResourceKey<V>, V>
      Parameters:
      key - The ID to register the value under. This ID only needs to be unique within your namespace.
      value - A supplier that produces the value to register.
      Returns:
      A reference to the registry entry.
    • id

      public final net.minecraft.resources.Identifier id(String key)
      Creates a new Identifier using the current namespace.
      Parameters:
      key - The path of the Identifier.
      Returns:
      A new Identifier with the current namespace.