类 AttachmentHolder
java.lang.Object
net.neoforged.neoforge.attachment.AttachmentHolder
- 所有已实现的接口:
IAttachmentHolder
- 直接已知子类:
AttachmentHolder.AsField
,BlockEntity
,Entity
,Level
Implementation class for objects that can hold data attachments.
For the user-facing methods, see
IAttachmentHolder
.-
嵌套类概要
嵌套类 -
字段概要
字段修饰符和类型字段说明(专用程序包) @Nullable Map
<AttachmentType<?>, Object> static final String
private static final boolean
private static final org.slf4j.Logger
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected final void
deserializeAttachments
(ValueInput input) Reads serializable attachments from a tag previously created viaserializeAttachments(ValueOutput)
.(专用程序包) final Map
<AttachmentType<?>, Object> Create the attachment map if it does not yet exist, or return the current map.final <T> T
getData
(AttachmentType<T> type) 返回 the data attachment of the given type。<T> T
getExistingDataOrNull
(AttachmentType<T> type) (专用程序包) IAttachmentHolder
Returns the attachment holder that is exposed to the user.final boolean
Returnstrue
if there is any data attachments,false
otherwise.final boolean
hasData
(AttachmentType<?> type) Returnstrue
if there is a data attachment of the give type,false
otherwise.<T> T
removeData
(AttachmentType<T> type) Removes the data attachment of the given type.final void
Writes the serializable attachments to a tag.<T> T
setData
(AttachmentType<T> type, T data) Sets the data attachment of the given type.private void
validateAttachmentType
(AttachmentType<?> type) 从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 net.neoforged.neoforge.attachment.IAttachmentHolder
getData, getExistingData, getExistingData, getExistingDataOrNull, hasData, removeData, setData
-
字段详细资料
-
ATTACHMENTS_NBT_KEY
- 另请参阅:
-
IN_DEV
private static final boolean IN_DEV -
LOGGER
private static final org.slf4j.Logger LOGGER -
attachments
-
-
构造器详细资料
-
AttachmentHolder
public AttachmentHolder()
-
-
方法详细资料
-
validateAttachmentType
-
getAttachmentMap
Create the attachment map if it does not yet exist, or return the current map. -
getExposedHolder
IAttachmentHolder getExposedHolder()Returns the attachment holder that is exposed to the user. This is the same asthis
for most cases, but when usingAttachmentHolder.AsField
it is the field holder. -
hasAttachments
public final boolean hasAttachments()从接口复制的说明:IAttachmentHolder
Returnstrue
if there is any data attachments,false
otherwise.- 指定者:
hasAttachments
在接口中IAttachmentHolder
-
hasData
从接口复制的说明:IAttachmentHolder
Returnstrue
if there is a data attachment of the give type,false
otherwise.- 指定者:
hasData
在接口中IAttachmentHolder
-
getData
从接口复制的说明:IAttachmentHolder
返回 the data attachment of the given type。If there is no data attachment of the given type, the default value is stored in this holder and returned.
- 指定者:
getData
在接口中IAttachmentHolder
- 返回:
- the data attachment of the given type
-
getExistingDataOrNull
- 指定者:
getExistingDataOrNull
在接口中IAttachmentHolder
- 返回:
- an existing data attachment value of the given type, or null if there is no data attachment of the given type
-
setData
从接口复制的说明:IAttachmentHolder
Sets the data attachment of the given type.- 指定者:
setData
在接口中IAttachmentHolder
- 返回:
- the previous value for that attachment type, if any, or
null
if there was none
-
removeData
从接口复制的说明:IAttachmentHolder
Removes the data attachment of the given type.- 指定者:
removeData
在接口中IAttachmentHolder
- 返回:
- the previous value for that attachment type, if any, or
null
if there was none
-
serializeAttachments
Writes the serializable attachments to a tag. -
deserializeAttachments
Reads serializable attachments from a tag previously created viaserializeAttachments(ValueOutput)
.
-