IData

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).

Importing the class

It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.

import crafttweaker.api.data.IData;

Casters

Result typeIs Implicit
ICollectionDatafalse
INumberDatafalse

Methods

asCollection

Return Type: ICollectionData

IData.asCollection() as ICollectionData
{Display: {lore: ["Hello", "World"]}}.asCollection();
asList

Gets a List representation of this IData, returns null on anything but ListData.

Return Type: stdlib.List<IData>

IData.asList() as stdlib.List<IData>
{Display: {lore: ["Hello", "World"]}}.asList();
asMap

Gets a Map<String, IData> representation of this IData, returns null on anything but MapData.

Return Type: IData[string]

IData.asMap() as IData[string]
{Display: {lore: ["Hello", "World"]}}.asMap();
asNumber

Return Type: INumberData

IData.asNumber() as INumberData
{Display: {lore: ["Hello", "World"]}}.asNumber();
asString

Gets the String representation of this IData

Return Type: string

IData.asString() as string
{Display: {lore: ["Hello", "World"]}}.asString();
contains

Checks if this IData contains another IData, mainly used in subclasses of ICollectionData, is the same as an equals check on other IData types

Return Type: boolean

IData.contains(data as IData) as boolean
{Display: {lore: ["Hello", "World"]}}.contains("Display");
ParameterTypeDescription
dataIDatadata to check if it is contained
copy

Makes a copy of this IData.

IData is immutable by default, use this to create a proper copy of the object.

Return Type: IData

IData.copy() as IData
{Display: {lore: ["Hello", "World"]}}.copy();
getId

Gets the ID of the internal NBT tag.

Used to determine what NBT type is stored (in a list for example)

Return Type: byte

IData.getId() as byte
{Display: {lore: ["Hello", "World"]}}.getId();
getString

Gets the String representation of the internal INBT tag

Return Type: string

IData.getString() as string
{Display: {lore: ["Hello", "World"]}}.getString();