接口 IRegistryExtension<T>
- 类型参数:
T
- the type of registry entries
- 所有已知子接口:
DefaultedRegistry<T>
,Registry<T>
,WritableRegistry<T>
public interface IRegistryExtension<T>
An extension for
Registry
, adding some additional functionality to vanilla registries, such as
callbacks and ID limits.-
方法概要
修饰符和类型方法说明void
addAlias
(ResourceLocation from, 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) 返回true
if this registry contains thevalue
。boolean
doesSync()
返回 whether this registry should be synced to clients。<A> Map
<ResourceKey<T>, A> getDataMap
(DataMapType<T, A> type) 返回 the data map of the giventype
。int
getId
(ResourceKey<T> key) Gets the integer id linked to the given key.int
getId
(ResourceLocation name) Gets the integer id linked to the given name.default @Nullable ResourceLocation
getKeyOrNull
(T element) 返回 the key of the element, or null if it is not present in this registry。int
getMaxId()
返回 the highest id that an entry in this registry is allowed to use。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.self()
-
方法详细资料
-
self
-
doesSync
boolean doesSync()返回 whether this registry should be synced to clients。- 返回:
- whether this registry should be synced to clients
-
getMaxId
int getMaxId()返回 the highest id that an entry in this registry is allowed to use。 For the size of this registry, seeIdMap.size()
.- 返回:
- 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.
- 参数:
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.- 参数:
type
- the type of the callback to addcallback
- the callback to add
-
addAlias
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.
- 参数:
from
- the source registry name to alias fromto
- the target registry name to alias to
-
resolve
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.- 参数:
name
- the input registry name of a potential object in this registry- 返回:
- 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.- 参数:
key
- the input registry key of a potential object in this registry- 返回:
- 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- 参数:
key
- the resource key to lookup- 返回:
- the integer id linked to the given key
-
getId
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- 参数:
name
- the resource name to lookup- 返回:
- the integer id linked to the given name
-
containsValue
返回true
if this registry contains thevalue
。- 参数:
value
- the object whose existence to check for- 返回:
true
if this registry contains thevalue
-
getDataMap
返回 the data map of the giventype
。- 类型参数:
A
- the data type- 返回:
- the data map of the given
type
-
getKeyOrNull
返回 the key of the element, or null if it is not present in this registry。- 返回:
- the key of the element, or null if it is not present in this registry
- API Note:
- This method is different from
Registry.getKey(Object)
as it does not return the default key fordefaulted registries
-