Class MappedRegistry<T>
java.lang.Object
net.neoforged.neoforge.registries.BaseMappedRegistry<T>
net.minecraft.core.MappedRegistry<T>
- All Implemented Interfaces:
com.mojang.serialization.Keyable, Iterable<T>, HolderGetter<T>, HolderLookup<T>, HolderLookup.RegistryLookup<T>, HolderOwner<T>, IdMap<T>, Registry<T>, WritableRegistry<T>, IRegistryExtension<T>
- Direct Known Subclasses:
DefaultedMappedRegistry
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface HolderLookup
HolderLookup.Provider, HolderLookup.RegistryLookup<T>Nested classes/interfaces inherited from interface HolderLookup.RegistryLookup
HolderLookup.RegistryLookup.Delegate<T>Nested classes/interfaces inherited from interface Registry
Registry.PendingTags<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate MappedRegistry.TagSet<T> private final it.unimi.dsi.fastutil.objects.ObjectList<Holder.Reference<T>> private final Map<ResourceKey<T>, Holder.Reference<T>> private final Map<Identifier, Holder.Reference<T>> private final Map<T, Holder.Reference<T>> private @Nullable DataComponentLookup<T> private booleanprivate final Map<TagKey<T>, HolderSet.Named<T>> private final ResourceKey<? extends Registry<T>> private final Map<ResourceKey<T>, RegistrationInfo> private com.mojang.serialization.Lifecycleprivate final it.unimi.dsi.fastutil.objects.Reference2IntMap<T> private @Nullable Map<T, Holder.Reference<T>> Fields inherited from class BaseMappedRegistry
addCallbacks, bakeCallbacks, clearCallbacks -
Constructor Summary
ConstructorsConstructorDescriptionMappedRegistry(ResourceKey<? extends Registry<T>> key, com.mojang.serialization.Lifecycle lifecycle) MappedRegistry(ResourceKey<? extends Registry<T>> key, com.mojang.serialization.Lifecycle initialLifecycle, boolean intrusiveHolders) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoid@Nullable TbyId(int id) protected voidclear(boolean full) booleancontainsKey(Identifier key) booleancontainsKey(ResourceKey<T> key) booleancontainsValue(T value) Returnstrueif this registry contains thevalue.createIntrusiveHolder(T value) private HolderSet.Named<T> Set<Map.Entry<ResourceKey<T>, T>> entrySet()freeze()get(int id) get(Identifier id) get(ResourceKey<T> id) getAny()intintgetId(Identifier name) Gets the integer id linked to the given name.intgetId(ResourceKey<T> key) Gets the integer id linked to the given key.@Nullable Identifierprivate Holder.Reference<T> private HolderSet.Named<T> getRandom(RandomSource random) getResourceKey(T thing) getTags()@Nullable TgetValue(@Nullable Identifier key) @Nullable TgetValue(@Nullable ResourceKey<T> key) private static <T> @Nullable TgetValueFromNullable(@Nullable Holder.Reference<T> result) booleanisEmpty()iterator()ResourceKey<? extends Registry<T>> key()keySet()listTags()private voidregister(int id, ResourceKey<T> key, T value, RegistrationInfo registrationInfo) register(ResourceKey<T> key, T value, RegistrationInfo registrationInfo) protected voidregisterIdMapping(ResourceKey<T> key, int id) Register a key invalid input: '<'-> ID mapping.registrationInfo(ResourceKey<T> element) Set<ResourceKey<T>> com.mojang.serialization.Lifecycleintsize()toString()voidunfreeze(boolean clearTags) Deprecated.Forge: For internal use only.private Holder.Reference<T> validateAndUnwrapTagElement(TagKey<T> id, Holder<T> value) private voidprivate voidvalidateWrite(ResourceKey<T> key) wrapAsHolder(T value) Methods inherited from class BaseMappedRegistry
addAlias, addCallback, doesSync, getData, getDataMap, getDataMaps, getMaxId, resolve, resolveMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface HolderGetter
getOrThrow, getOrThrow, getRandomElementOfMethods inherited from interface HolderLookup
listElementIds, listTagIdsMethods inherited from interface HolderLookup.RegistryLookup
filterElements, filterFeatures, getDataMethods inherited from interface HolderOwner
canSerializeInMethods inherited from interface IdMap
byIdOrThrow, getIdOrThrowMethods inherited from interface IRegistryExtension
addAlias, addCallback, addCallback, doesSync, getDataMap, getKeyOrNull, getMaxId, resolve, resolveMethods inherited from interface Iterable
forEach, spliteratorMethods inherited from interface Registry
asHolderIdMap, byNameCodec, getOptional, getOptional, getTagOrEmpty, getValueOrThrow, holderByNameCodec, keys, stream
-
Field Details
-
key
-
byId
-
toId
-
byLocation
-
byKey
-
byValue
-
registrationInfos
-
registryLifecycle
private com.mojang.serialization.Lifecycle registryLifecycle -
frozenTags
-
allTags
-
componentLookup
-
frozen
private boolean frozen -
unregisteredIntrusiveHolders
-
-
Constructor Details
-
MappedRegistry
public MappedRegistry(ResourceKey<? extends Registry<T>> key, com.mojang.serialization.Lifecycle lifecycle) -
MappedRegistry
public MappedRegistry(ResourceKey<? extends Registry<T>> key, com.mojang.serialization.Lifecycle initialLifecycle, boolean intrusiveHolders)
-
-
Method Details
-
listTags
- Specified by:
listTagsin interfaceHolderLookup<T>
-
key
-
toString
-
validateWrite
private void validateWrite() -
validateWrite
-
register
- Specified by:
registerin interfaceWritableRegistry<T>
-
register
public Holder.Reference<T> register(int id, ResourceKey<T> key, T value, RegistrationInfo registrationInfo) -
getKey
-
getResourceKey
- Specified by:
getResourceKeyin interfaceRegistry<T>
-
getId
-
getValue
-
byId
-
get
-
get
-
get
- Specified by:
getin interfaceHolderGetter<T>
-
getAny
-
wrapAsHolder
-
getOrCreateHolderOrThrow
-
size
-
registrationInfo
- Specified by:
registrationInfoin interfaceRegistry<T>
-
registryLifecycle
public com.mojang.serialization.Lifecycle registryLifecycle()- Specified by:
registryLifecyclein interfaceHolderLookup.RegistryLookup<T>
-
iterator
-
getValue
-
getValueFromNullable
-
keySet
-
registryKeySet
- Specified by:
registryKeySetin interfaceRegistry<T>
-
entrySet
-
listElements
- Specified by:
listElementsin interfaceHolderLookup<T>
-
getTags
-
getOrCreateTagForRegistration
-
createTag
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceWritableRegistry<T>
-
getRandom
-
containsKey
- Specified by:
containsKeyin interfaceRegistry<T>
-
containsKey
- Specified by:
containsKeyin interfaceRegistry<T>
-
componentLookup
- Specified by:
componentLookupin interfaceRegistry<T>
-
unfreeze
Deprecated.Forge: For internal use only. Use the Register events when registering values.- Specified by:
unfreezein classBaseMappedRegistry<T>
-
freeze
-
createIntrusiveHolder
- Specified by:
createIntrusiveHolderin interfaceRegistry<T>
-
get
- Specified by:
getin interfaceHolderGetter<T>
-
validateAndUnwrapTagElement
-
bindTags
-
refreshTagsInHolders
private void refreshTagsInHolders() -
bindAllTagsToEmpty
public void bindAllTagsToEmpty() -
createRegistrationLookup
- Specified by:
createRegistrationLookupin interfaceWritableRegistry<T>
-
prepareTagReload
- Specified by:
prepareTagReloadin interfaceRegistry<T>
-
clear
protected void clear(boolean full) - Overrides:
clearin classBaseMappedRegistry<T>
-
registerIdMapping
Description copied from class:BaseMappedRegistryRegister a key invalid input: '<'-> ID mapping. The IDs must be registered in increasing order.- Specified by:
registerIdMappingin classBaseMappedRegistry<T>
-
getId
Description copied from interface:IRegistryExtensionGets the integer id linked to the given name. If the name is not present in the registry, the default entry's integer id is returned if the registry is defaulted or-1if the registry is not defaulted- Specified by:
getIdin interfaceIRegistryExtension<T>- Overrides:
getIdin classBaseMappedRegistry<T>- Parameters:
name- the resource name to lookup- Returns:
- the integer id linked to the given name
-
getId
Description copied from interface:IRegistryExtensionGets the integer id linked to the given key. If the key is not present in the registry, the default entry's integer id is returned if the registry is defaulted or-1if the registry is not defaulted- Specified by:
getIdin interfaceIRegistryExtension<T>- Overrides:
getIdin classBaseMappedRegistry<T>- Parameters:
key- the resource key to lookup- Returns:
- the integer id linked to the given key
-
containsValue
Description copied from interface:IRegistryExtensionReturnstrueif this registry contains thevalue.- Specified by:
containsValuein interfaceIRegistryExtension<T>- Parameters:
value- the object whose existence to check for- Returns:
trueif this registry contains thevalue
-