Package com.simibubi.create.api.registry
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 ClassesModifier and TypeInterfaceDescriptionstatic interfaceAn extension of SimpleRegistry that handles multiple registrations per object.static interfaceA provider can provide values to the registry in a lazy fashion. -
Method Summary
Modifier and TypeMethodDescriptionstatic <K,V> SimpleRegistry <K, V> create()Query the value associated with the given object.Shortcut forget(Object)that accepts a StateHolder, such as BlockState or FluidState.voidInvalidate the cached values provided by all providers, so they get re-computed on the next query.voidRegister an association between a key and a value.voidregisterProvider(SimpleRegistry.Provider<K, V> provider) Add a new provider to this registry.
-
Method Details
-
register
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
Add a new provider to this registry. For information on providers, seeSimpleRegistry.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
Query the value associated with the given object. May be null if no association is present. -
get
Shortcut forget(Object)that accepts a StateHolder, such as BlockState or FluidState. -
create
-