Interface SimpleRegistry<K,V>

All Known Subinterfaces:
SimpleRegistry.Multi<K,V>
All Known Implementing Classes:
SimpleRegistryImpl

@NonExtendable public interface SimpleRegistry<K,V>
A simple registry mapping between objects with identity semantics. Provides simple registration functionality, as well as lazy providers. This class is thread-safe, and may be safely used during parallel mod init.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    An extension of SimpleRegistry that handles multiple registrations per object.
    static interface 
    A provider can provide values to the registry in a lazy fashion.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <K, V> SimpleRegistry<K,V>
     
    get(K object)
    Query the value associated with the given object.
    get(net.minecraft.world.level.block.state.StateHolder<K,?> state)
    Shortcut for get(Object) that accepts a StateHolder, such as BlockState or FluidState.
    void
    Invalidate the cached values provided by all providers, so they get re-computed on the next query.
    void
    register(K object, V value)
    Register an association between a key and a value.
    void
    Add a new provider to this registry.
  • Method Details

    • register

      void register(K object, V value)
      Register an association between a key and a value. Direct registrations here always take priority over providers.
      Throws:
      IllegalArgumentException - if the object already has an associated value
    • registerProvider

      void registerProvider(SimpleRegistry.Provider<K,V> provider)
      Add a new provider to this registry. For information on providers, see SimpleRegistry.Provider.
      Throws:
      IllegalArgumentException - if the provider has already been registered to this registry
    • invalidate

      void invalidate()
      Invalidate the cached values provided by all providers, so they get re-computed on the next query. This should be called by providers when something changes that would affect their results, such as a resource reload in the case of providers based on tags.
    • get

      @Nullable V get(K object)
      Query the value associated with the given object. May be null if no association is present.
    • get

      @Nullable V get(net.minecraft.world.level.block.state.StateHolder<K,?> state)
      Shortcut for get(Object) that accepts a StateHolder, such as BlockState or FluidState.
    • create

      static <K, V> SimpleRegistry<K,V> create()