类 DeferredHolder<R,T extends R>
java.lang.Object
net.neoforged.neoforge.registries.DeferredHolder<R,T>
- 类型参数:
T
- The type of object being held by this DeferredHolder.
- 所有已实现的接口:
Supplier<T>
,Holder<R>
,IHolderExtension<R>
,IWithData<R>
A Deferred Holder is a
Holder
that is constructed with only a ResourceKey.
It will be populated with the underlying Holder from the registry when available.
-
嵌套类概要
从接口继承的嵌套类/接口 net.minecraft.core.Holder
Holder.Direct<T>, Holder.Kind, Holder.Reference<T>
-
字段概要
字段 -
构造器概要
构造器限定符构造器说明protected
DeferredHolder
(ResourceKey<R> key) Creates a new DeferredHolder with a ResourceKey. -
方法概要
修饰符和类型方法说明Returns an optional containing the target object, ifbound
; otherwise an empty optional.protected final void
bind
(boolean throwOnMissingRegistry) Binds this DeferredHolder to the underlying registry and target object.boolean
canSerializeIn
(HolderOwner<R> owner) static <R,
T extends R>
DeferredHolder<R, T> create
(ResourceKey<? extends Registry<R>> registryKey, ResourceLocation valueName) Creates a new DeferredHolder targeting the value with the specified name in the specified registry.static <R,
T extends R>
DeferredHolder<R, T> create
(ResourceKey<R> key) Creates a new DeferredHolder targeting the specified value.static <R,
T extends R>
DeferredHolder<R, T> create
(ResourceLocation registryName, ResourceLocation valueName) Creates a new DeferredHolder targeting the value with the specified name in the specified registry.boolean
get()
Gets the object stored by this DeferredHolder, if this holder is bound.<Z> Z
getData
(DataMapType<R, Z> type) 返回 the data of the given type that is attached to this object, ornull
if one isn't。返回 the holder that this holder wraps。getId()
getKey()
Get the resource key held by this Holder, or null if none is present.Returns the registry that this DeferredHolder is pointing at, ornull
if it doesn't exist.int
hashCode()
boolean
is
(Predicate<ResourceKey<R>> filter) Evaluates the passed predicate against this holder's resource key.boolean
已过时。boolean
is
(ResourceKey<R> key) 返回 true if the passed ResourceKey is the same as this holder's resource key。boolean
is
(ResourceLocation id) 返回 true if the passed ResourceLocation is the same as the ID of the target object。boolean
返回 true if this holder is a member of the passed tag。boolean
isBound()
返回 true if the underlying object is available。kind()
tags()
返回 all tags present on the underlying object。toString()
com.mojang.datafixers.util.Either
<ResourceKey<R>, R> unwrap()
Returns anEither.left()
containing the resource key of this holder.Returns the resource key of this holder.value()
Gets the object stored by this DeferredHolder, if this holder is bound.从接口继承的方法 net.minecraft.core.Holder
getRegisteredName
从接口继承的方法 net.neoforged.neoforge.common.extensions.IHolderExtension
unwrapLookup
-
字段详细资料
-
key
The resource key of the target object. -
holder
The currently cached value.
-
-
构造器详细资料
-
DeferredHolder
Creates a new DeferredHolder with a ResourceKey.Attempts to bind immediately if possible.
- 参数:
key
- The resource key of the target object.- 另请参阅:
-
-
方法详细资料
-
create
public static <R,T extends R> DeferredHolder<R,T> create(ResourceKey<? extends Registry<R>> registryKey, ResourceLocation valueName) Creates a new DeferredHolder targeting the value with the specified name in the specified registry.- 类型参数:
R
- The registry type.T
- The type of the target value.- 参数:
registryKey
- The name of the registry the target value is a member of.valueName
- The name of the target value.
-
create
public static <R,T extends R> DeferredHolder<R,T> create(ResourceLocation registryName, ResourceLocation valueName) Creates a new DeferredHolder targeting the value with the specified name in the specified registry.- 类型参数:
T
- The registry type.- 参数:
registryName
- The name of the registry the target value is a member of.valueName
- The name of the target value.
-
create
Creates a new DeferredHolder targeting the specified value.- 类型参数:
T
- The type of the target value.- 参数:
key
- The resource key of the target value.
-
value
Gets the object stored by this DeferredHolder, if this holder is bound.- 指定者:
value
在接口中Holder<R>
- 抛出:
IllegalStateException
- If the backing registry is unavailable.NullPointerException
- If the underlying Holder has not been populated (the target object is not registered).
-
get
Gets the object stored by this DeferredHolder, if this holder is bound.- 指定者:
get
在接口中Supplier<R>
- 抛出:
IllegalStateException
- If the backing registry is unavailable.NullPointerException
- If the underlying Holder has not been populated (the target object is not registered).
-
asOptional
Returns an optional containing the target object, ifbound
; otherwise an empty optional.- 返回:
- an optional containing the target object, if
bound
; otherwise an empty optional
-
getRegistry
Returns the registry that this DeferredHolder is pointing at, ornull
if it doesn't exist.- 返回:
- the registry that this DeferredHolder is pointing at, or
null
if it doesn't exist
-
bind
protected final void bind(boolean throwOnMissingRegistry) Binds this DeferredHolder to the underlying registry and target object.Has no effect if already bound.
- 参数:
throwOnMissingRegistry
- If true, an exception will be thrown if the registry is absent.- 抛出:
IllegalStateException
- If throwOnMissingRegistry is true and the backing registry is unavailable.
-
getId
- 返回:
- The ID of the object pointed to by this DeferredHolder.
-
getKey
从接口复制的说明:IHolderExtension
Get the resource key held by this Holder, or null if none is present. This method will be overriden by Holder implementations to avoid allocation associated withHolder.unwrapKey()
- 指定者:
getKey
在接口中IHolderExtension<R>
- 返回:
- The ResourceKey of the object pointed to by this DeferredHolder.
-
equals
-
hashCode
public int hashCode() -
toString
-
isBound
public boolean isBound() -
is
返回 true if the passed ResourceLocation is the same as the ID of the target object。 -
is
返回 true if the passed ResourceKey is the same as this holder's resource key。 -
is
Evaluates the passed predicate against this holder's resource key.- 指定者:
is
在接口中Holder<R>
- 返回:
true
if the filter matches this DH's resource key
-
is
返回 true if this holder is a member of the passed tag。 -
is
已过时。返回true
if theholder
is the same as this holder。 -
getData
返回 the data of the given type that is attached to this object, ornull
if one isn't。 -
tags
返回 all tags present on the underlying object。If the underlying object is not bound yet, and empty stream is returned.
-
unwrap
Returns anEither.left()
containing the resource key of this holder. -
unwrapKey
Returns the resource key of this holder. -
kind
-
canSerializeIn
- 指定者:
canSerializeIn
在接口中Holder<R>
-
getDelegate
从接口复制的说明:IHolderExtension
返回 the holder that this holder wraps。 Used byRegistry.safeCastToReference(net.minecraft.core.Holder<T>)
to resolve the underlyingHolder.Reference
for delegating holders.- 指定者:
getDelegate
在接口中IHolderExtension<R>
- 返回:
- the holder that this holder wraps
-