Interface Tag<T extends @UnknownNullability Object>
- Type Parameters:
T- the tag type
- All Known Implementing Classes:
TagImpl
Represents a key to retrieve or change a value.
All tags are serializable.
-
Method Summary
Modifier and TypeMethodDescriptiondefaultValue(Supplier<T> defaultValue) defaultValue(T defaultValue) getKey()Deprecated.booleanisView()key()Returns the key for the Tag
Same key specified during the creation.list()<R> Tag<R> Creates a flexible tag able to read and write anyBinaryTagobjects.read(CompoundBinaryTag nbt) booleanshareValue(Tag<?> other) static <T> Tag<T> Structure(String key, TagSerializer<T> serializer) Creates a tag containing multiple fields.static <T> Tag<T> Creates a transient tag with the specified key.static <T> Tag<T> View(TagSerializer<T> serializer) Specialized Structure tag affecting the src of the handler (i.e.voidwrite(CompoundBinaryTag.Builder nbtCompound, T value) voidwriteUnsafe(CompoundBinaryTag.Builder nbtCompound, @Nullable Object value)
-
Method Details
-
Byte
-
Boolean
-
Short
-
Integer
-
Long
-
Float
-
Double
-
String
-
UUID
-
ItemStack
-
Component
-
NBT
-
Structure
Creates a tag containing multiple fields.Those fields cannot be modified from an outside tag. (This is to prevent the backed object from becoming out of sync)
- Type Parameters:
T- the tag type- Parameters:
key- the tag keyserializer- the tag serializer- Returns:
- the created tag
-
View
Specialized Structure tag affecting the src of the handler (i.e. overwrite all its data).Must be used with care.
-
Structure
-
View
-
Transient
Creates a transient tag with the specified key. This tag does not get serialized to NBT (Named Binary Tag) format and is not sent to the client. Unlike other tags, which are serialized, transient tags are used for temporary data that only needs to exist on the server side.- Type Parameters:
T- The type of the tag's value.- Parameters:
key- The key.- Returns:
- A transient tag with the key.
-
getKey
-
key
String key()Returns the key for the Tag
Same key specified during the creation.- Returns:
- the key to use
-
defaultValue
-
defaultValue
-
map
-
list
-
path
-
read
-
write
-
writeUnsafe
-
isView
boolean isView() -
createDefault
T createDefault() -
copyValue
-
key()instead.