Class BaseMappedRegistry<T>
java.lang.Object
net.neoforged.neoforge.registries.BaseMappedRegistry<T>
- All Implemented Interfaces:
com.mojang.serialization.Keyable,Iterable<T>,IdMap<T>,Registry<T>,IRegistryExtension<T>
- Direct Known Subclasses:
MappedRegistry
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final List<AddCallback<T>> (package private) final Map<ResourceLocation, ResourceLocation> protected final List<BakeCallback<T>> protected final List<ClearCallback<T>> (package private) final Map<DataMapType<T, ?>, Map<ResourceKey<T>, ?>> private intprivate boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAlias(ResourceLocation from, ResourceLocation to) Adds an alias that maps from the name specified byfromto the name specified byto.voidaddCallback(RegistryCallback<T> callback) Adds a callback to this registry.protected voidclear(boolean full) booleandoesSync()Returns whether this registry should be synced to clients.<A> AgetData(DataMapType<T, A> type, ResourceKey<T> key) Returns the data map value attached with the object with the key, ornullif there's no attached value.<A> Map<ResourceKey<T>, A> getDataMap(DataMapType<T, A> type) Returns the data map of the giventype.intgetId(ResourceKey<T> key) Gets the integer id linked to the given key.intgetId(ResourceLocation name) Gets the integer id linked to the given name.intgetMaxId()Returns the highest id that an entry in this registry is allowed to use.protected abstract voidregisterIdMapping(ResourceKey<T> key, int id) Register a key invalid input: '<'-> ID mapping.resolve(ResourceKey<T> key) Resolves a registry key of a potential object in this registry.resolve(ResourceLocation name) Resolves a registry name of a potential object in this registry.(package private) voidsetMaxId(int maxId) (package private) voidsetSync(boolean sync) protected abstract voidunfreeze()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.core.IdMap
byId, byIdOrThrow, getIdOrThrow, sizeMethods inherited from interface net.neoforged.neoforge.registries.IRegistryExtension
addCallback, containsValueMethods inherited from interface java.lang.Iterable
forEach, iterator, spliteratorMethods inherited from interface net.minecraft.core.Registry
asHolderIdMap, asLookup, asTagAddingLookup, bindTags, byNameCodec, containsKey, containsKey, createIntrusiveHolder, entrySet, freeze, get, get, getAny, getHolder, getHolder, getHolder, getHolderOrThrow, getId, getKey, getOptional, getOptional, getOrCreateTag, getOrThrow, getRandom, getRandomElementOf, getResourceKey, getTag, getTagNames, getTagOrEmpty, getTags, holderByNameCodec, holderOwner, holders, key, keys, keySet, registrationInfo, registryKeySet, registryLifecycle, resetTags, stream, wrapAsHolder
-
Field Details
-
addCallbacks
-
bakeCallbacks
-
clearCallbacks
-
aliases
-
dataMaps
-
maxId
private int maxId -
sync
private boolean sync
-
-
Constructor Details
-
BaseMappedRegistry
public BaseMappedRegistry()
-
-
Method Details
-
setSync
void setSync(boolean sync) -
doesSync
public boolean doesSync()Description copied from interface:IRegistryExtensionReturns whether this registry should be synced to clients.- Specified by:
doesSyncin interfaceIRegistryExtension<T>- Returns:
- whether this registry should be synced to clients
-
setMaxId
void setMaxId(int maxId) -
getMaxId
public int getMaxId()Description copied from interface:IRegistryExtensionReturns the highest id that an entry in this registry is allowed to use. For the size of this registry, seeIdMap.size().- Specified by:
getMaxIdin interfaceIRegistryExtension<T>- Returns:
- the highest id that an entry in this registry is allowed to use
-
addCallback
Description copied from interface:IRegistryExtensionAdds a callback to this registry.Depending on the interfaces implemented by the object, the callback will be called when the registry is added to, baked, and/or cleared.
- Specified by:
addCallbackin interfaceIRegistryExtension<T>- Parameters:
callback- the callback to add
-
addAlias
Description copied from interface:IRegistryExtensionAdds an alias that maps from the name specified byfromto the name specified byto.Any registry lookups that target the first name will resolve as the second name, if the first name is not present.
- Specified by:
addAliasin interfaceIRegistryExtension<T>- Parameters:
from- the source registry name to alias fromto- the target registry name to alias to
-
resolve
Description copied from interface:IRegistryExtensionResolves a registry name of a potential object in this registry. The original name will be returned if it is contained in this registry. If not, the alias map will be checked for entries. Resolving supports alias chains (A -> B -> C) and will terminate when an alias has an entry or the last alias in the chain is reached.- Specified by:
resolvein interfaceIRegistryExtension<T>- Parameters:
name- the input registry name of a potential object in this registry- Returns:
- the resolved registry name
-
resolve
Description copied from interface:IRegistryExtensionResolves a registry key of a potential object in this registry. The original key will be returned if it is contained in this registry. If not, the alias map will be checked for entries. Resolving supports alias chains (A -> B -> C) and will terminate when an alias has an entry or the last alias in the chain is reached.- Specified by:
resolvein interfaceIRegistryExtension<T>- Parameters:
key- the input registry key of a potential object in this registry- Returns:
- the resolved registry key
-
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>- Parameters:
key- the resource key to lookup- Returns:
- the integer id linked to the given key
-
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>- Parameters:
name- the resource name to lookup- Returns:
- the integer id linked to the given name
-
clear
protected void clear(boolean full) -
registerIdMapping
Register a key invalid input: '<'-> ID mapping. The IDs must be registered in increasing order. -
unfreeze
protected abstract void unfreeze() -
getData
Description copied from interface:IRegistryExtensionReturns the data map value attached with the object with the key, ornullif there's no attached value.- Specified by:
getDatain interfaceIRegistryExtension<T>- Type Parameters:
A- the data type- Parameters:
type- the type of the data mapkey- the object to get the value for- Returns:
- the data map value attached with the object with the key, or
nullif there's no attached value
-
getDataMap
Description copied from interface:IRegistryExtensionReturns the data map of the giventype.- Specified by:
getDataMapin interfaceIRegistryExtension<T>- Type Parameters:
A- the data type- Returns:
- the data map of the given
type
-