Schnittstelle Registry<K,V>
- Typparameter:
K- Key Type.V- Value Type.
- Alle bekannten Implementierungsklassen:
GenericRegistry
public interface Registry<K,V>
Generic registry interface for key-value storage with freeze support.
-
Methodenübersicht
Modifikator und TypMethodeBeschreibungvoidclear()Clear the registry (only if not frozen).booleanCheck if the registry contains a key.voidforEach(BiConsumer<K, V> kvConsumer) Iterate over all key-value pairs.voidIterate over all values.voidfreeze()Freeze the registry, making it immutable.Get the value directly (legacy method, prefer getRef()).Get the key for a given value (reverse lookup).getRandom(net.minecraft.util.RandomSource random) Get a random value from the registry.Get a reference to the registry entry.booleanisEmpty()Check if the registry is empty.booleanisFrozen()Check if the registry is frozen (immutable).keys()Get all keys in the registry.booleanRegister a callback to run when the registry is frozen.voidRegister a key-value pair in this registry.voidRemove a key from this registry.intsize()Get the number of entries in the registry.stream()Stream all values.Try to get a value, returning Optional.voidunfreeze()Unfreeze the registry, allowing modifications again.values()Get all values in the registry.
-
Methodendetails
-
register
-
remove
Remove a key from this registry. -
get
-
getRef
Get a reference to the registry entry. This is the preferred way to access registry entries.- Gibt zurück:
- RegistryRef that can be cached and provides lazy loading
-
getKey
-
getRandom
Get a random value from the registry. -
tryGet
-
contains
Check if the registry contains a key. -
values
Collection<V> values()Get all values in the registry. -
keys
Collection<K> keys()Get all keys in the registry. -
isFrozen
boolean isFrozen()Check if the registry is frozen (immutable). -
isEmpty
boolean isEmpty()Check if the registry is empty. -
freeze
void freeze()Freeze the registry, making it immutable. -
unfreeze
void unfreeze()Unfreeze the registry, allowing modifications again. -
onFreeze
Register a callback to run when the registry is frozen.- Gibt zurück:
- true if callback was added, false if already frozen (callback ran immediately)
-
forEach
Iterate over all key-value pairs. -
forEach
-
stream
-
clear
Clear the registry (only if not frozen).- Löst aus:
IllegalStateException
-
size
int size()Get the number of entries in the registry.
-