Interface IData
- All Known Subinterfaces:
ICollectionData,INumberData
- All Known Implementing Classes:
BoolData,ByteArrayData,ByteData,DoubleData,FloatData,IntArrayData,IntData,ListData,LongArrayData,LongData,MapData,ShortData,StringData
The IData interface is a generic Interface for handling Data like NBT.
You can cast about all primitives (short, double, string, int, ...) as well as certain arrays to IData.
Remember that while they offer similar features, IData and their counterparts are NOT the same, which is why they will be referred to as DataTypes (e.g.
ByteData).- DocParam:
- this {Display: {lore: ["Hello", "World"]}}
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumUsed to specify what "type" of IData this is. -
Method Summary
Modifier and TypeMethodDescription<T> Taccept(DataVisitor<T> visitor) default booleandefault ICollectionDataasList()Gets a Listrepresentation of this IData, returns null on anything but ListData.asMap()Gets a Map<String, IData> representation of this IData, returns null on anything butMapData.default INumberDataasNumber()default StringasString()Gets the String representation of this IDatadefault booleanChecks if this IData contains another IData, mainly used in subclasses ofICollectionData, is the same as an equals check on other IData typescopy()Makes a copy of this IData.Makes a copy of this IData with a copy of the internal INBT object.default bytegetId()Gets the ID of the internal NBT tag.net.minecraft.nbt.TagGets the internal INBT stored in this IData.default StringGets the String representation of the internal INBT taggetType()Gets the type of this IData.
-
Method Details
-
getId
default byte getId()Gets the ID of the internal NBT tag. Used to determine what NBT type is stored (in a list for example)- Returns:
- ID of the NBT tag that this data represents.
-
copy
IData copy()Makes a copy of this IData. IData is immutable by default, use this to create a proper copy of the object.- Returns:
- a copy of this IData.
-
copyInternal
IData copyInternal()Makes a copy of this IData with a copy of the internal INBT object.- Returns:
- a copy of this IData with a copy of the internal INBT object.
-
getInternal
net.minecraft.nbt.Tag getInternal()Gets the internal INBT stored in this IData.- Returns:
- the vanilla INBT tag that this IData represents.
-
getString
Gets the String representation of the internal INBT tag- Returns:
- String that represents the internal INBT of this IData.
-
contains
Checks if this IData contains another IData, mainly used in subclasses ofICollectionData, is the same as an equals check on other IData types- Parameters:
data- data to check if it is contained- Returns:
- true if the given IData is contained in this IData
- DocParam:
- data "Display"
-
asMap
Gets a Map<String, IData> representation of this IData, returns null on anything butMapData.- Returns:
- null if this IData is not a map.
-
asList
Gets a Listrepresentation of this IData, returns null on anything but ListData.- Returns:
- null if this IData is not a list.
-
asString
Gets the String representation of this IData- Returns:
- String that represents this IData (value and type).
-
asNumber
-
asCollection
-
asBoolean
default boolean asBoolean() -
getType
IData.Type getType()Gets the type of this IData.- Returns:
- The type of this IData.
-
accept
-