Interface IRegistryExtension<T>
- Type Parameters:
T
- the type of registry entries
- All Known Implementing Classes:
BaseMappedRegistry
public interface IRegistryExtension<T>
An extension for
Registry
, adding some additional functionality to vanilla registries, such as
callbacks and ID limits.-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAlias
(net.minecraft.resources.ResourceLocation from, net.minecraft.resources.ResourceLocation to) Adds an alias that maps from the name specified byfrom
to the name specified byto
.default <C extends RegistryCallback<T>>
voidaddCallback
(Class<C> type, C callback) Adds a lambda-implemented callback to this registry.void
addCallback
(RegistryCallback<T> callback) Adds a callback to this registry.boolean
containsValue
(T value) Returnstrue
if this registry contains thevalue
.boolean
doesSync()
Returns whether this registry should be synced to clients.getDataMap
(DataMapType<T, A> type) Returns the data map of the giventype
.int
Gets the integer id linked to the given key.int
getId
(net.minecraft.resources.ResourceLocation name) Gets the integer id linked to the given name.default @Nullable net.minecraft.resources.ResourceLocation
getKeyOrNull
(T element) Returns the key of the element, or null if it is not present in this registry.int
getMaxId()
Returns the highest id that an entry in this registry is allowed to use.net.minecraft.resources.ResourceKey
<T> Resolves a registry key of a potential object in this registry.net.minecraft.resources.ResourceLocation
resolve
(net.minecraft.resources.ResourceLocation name) Resolves a registry name of a potential object in this registry.private net.minecraft.core.Registry
<T> self()
-
Method Details
-
self
-
doesSync
boolean doesSync()Returns whether this registry should be synced to clients.- Returns:
- whether this registry should be synced to clients
-
getMaxId
int getMaxId()Returns the highest id that an entry in this registry is allowed to use. For the size of this registry, seeIdMap.size()
.- Returns:
- the highest id that an entry in this registry is allowed to use
-
addCallback
Adds 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.
- Parameters:
callback
- the callback to add
-
addCallback
Adds a lambda-implemented callback to this registry.The callback will be called when the registry is added to, baked, or cleared. The
Class
parameter is used to determine the lambda type.- Parameters:
type
- the type of the callback to addcallback
- the callback to add
-
addAlias
void addAlias(net.minecraft.resources.ResourceLocation from, net.minecraft.resources.ResourceLocation to) Adds an alias that maps from the name specified byfrom
to 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.
- Parameters:
from
- the source registry name to alias fromto
- the target registry name to alias to
-
resolve
net.minecraft.resources.ResourceLocation resolve(net.minecraft.resources.ResourceLocation name) Resolves 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.- Parameters:
name
- the input registry name of a potential object in this registry- Returns:
- the resolved registry name
-
resolve
Resolves 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.- Parameters:
key
- the input registry key of a potential object in this registry- Returns:
- the resolved registry key
-
getId
Gets 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-1
if the registry is not defaulted- Parameters:
key
- the resource key to lookup- Returns:
- the integer id linked to the given key
-
getId
int getId(net.minecraft.resources.ResourceLocation name) Gets 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-1
if the registry is not defaulted- Parameters:
name
- the resource name to lookup- Returns:
- the integer id linked to the given name
-
containsValue
Returnstrue
if this registry contains thevalue
.- Parameters:
value
- the object whose existence to check for- Returns:
true
if this registry contains thevalue
-
getDataMap
Returns the data map of the giventype
.- Type Parameters:
A
- the data type- Returns:
- the data map of the given
type
-
getKeyOrNull
Returns the key of the element, or null if it is not present in this registry.- Returns:
- the key of the element, or null if it is not present in this registry
-