Home Getting Started With Scripts Using this wiki Commands CTGUI Global functions Bracket Handlers

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

Importing the package

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.
import crafttweaker.data.IData;

Overview

| Binary Operators | + | - | * | / | % | & | | | ^ | in | == | <, >, <=, >= | |-----------------------------------|-----|-----|-----|-----|-----|-----|-----|-----|------|------|----------------| | DataBool | ✘ | ✘ | ✘ | ✘ | ✘ | ✔ | ✔ | ✔ | ✔ | ✔ | ✘ | | DataByte | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | | DataByte[] | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✔ | ✔ | ✘ | | DataDouble | ✔ | ✔ | ✔ | ✔ | ✔ | ✘ | ✘ | ✘ | ✔ | ✔ | ✔ | | DataFloat | ✔ | ✔ | ✔ | ✔ | ✔ | ✘ | ✘ | ✘ | ✔ | ✔ | ✔ | | DataInt | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | | DataInt[] | ✔ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✔ | ✔ | ✘ | | DataList | ✔ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✔ | ✔ | ✘ | | DataLong | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | | DataMap | ✔ | ✔ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✔ | ✔ | ✘ | | DataShort | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | | DataString | ✔ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✔ | ✔ | ✔ |

Unary Oparators- negate! not
Unary Oparators
DataBool
- negate
✘
! not
✔
Unary Oparators
DataByte
- negate
✔
! not
✔
Unary Oparators
DataByte[]
- negate
✘
! not
✘
Unary Oparators
DataDouble
- negate
✔
! not
✘
Unary Oparators
DataFloat
- negate
✔
! not
✘
Unary Oparators
DataInt
- negate
✔
! not
✔
Unary Oparators
DataInt[]
- negate
✘
! not
✘
Unary Oparators
DataList
- negate
✘
! not
✘
Unary Oparators
DataLong
- negate
✔
! not
✔
Unary Oparators
DataMap
- negate
✘
! not
✘
Unary Oparators
DataShort
- negate
✔
! not
✔
Unary Oparators
DataString
- negate
✘
! not
✘
Index and Members[i][i]=v.member.member=v.length.immutable.update(v)
Index and Members
DataBool
[i]
✘
[i]=v
✘
.member
✘
.member=v
✘
.length
returns 0
.immutable
✔
.update(v)
✔
Index and Members
DataByte
[i]
✘
[i]=v
✘
.member
✘
.member=v
✘
.length
returns 0
.immutable
✔
.update(v)
✔
Index and Members
DataByte[]
[i]
✔
[i]=v
✔
.member
✘
.member=v
✘
.length
✔
.immutable
✔
.update(v)
✔
Index and Members
DataDouble
[i]
✘
[i]=v
✘
.member
✘
.member=v
✘
.length
returns 0
.immutable
✔
.update(v)
✔
Index and Members
DataFloat
[i]
✘
[i]=v
✘
.member
✘
.member=v
✘
.length
returns 0
.immutable
✔
.update(v)
✔
Index and Members
DataInt
[i]
✘
[i]=v
✘
.member
✘
.member=v
✘
.length
returns 0
.immutable
✔
.update(v)
✔
Index and Members
DataInt[]
[i]
✔
[i]=v
✔
.member
✘
.member=v
✘
.length
✔
.immutable
✔
.update(v)
✔
Index and Members
DataList
[i]
✔
[i]=v
✔
.member
✘
.member=v
✘
.length
✔
.immutable
✔
.update(v)
✔
Index and Members
DataLong
[i]
✘
[i]=v
✘
.member
✘
.member=v
✘
.length
returns 0
.immutable
✔
.update(v)
✔
Index and Members
DataMap
[i]
✘
[i]=v
✘
.member
✔
.member=v
✔
.length
✔
.immutable
✔
.update(v)
✔
Index and Members
DataShort
[i]
✘
[i]=v
✘
.member
✘
.member=v
✘
.length
returns 0
.immutable
✔
.update(v)
✔
Index and Members
DataString
[i]
✔
[i]=v
✘
.member
✘
.member=v
✘
.length
✔
.immutable
✔
.update(v)
✔

You can cast IData to a specific type using data.asType() → data.asInt();
You can also use the IData Interface to convert types: ("1" as IData).asInt();

Casts from ↓ to →boolbytebyte[]doublefloatintint[]listlongMapshortstring
Casts from ↓ to →
DataBool
bool
≡
byte
✔
byte[]
null
double
✔
float
✔
int
✔
int[]
null
list
null
long
✔
null
short
✔
string
✔
Casts from ↓ to →
DataByte
bool
✔
byte
≡
byte[]
null
double
✔
float
✔
int
✔
int[]
null
list
null
long
✔
null
short
✔
string
✔
Casts from ↓ to →
DataByte[]
bool
✘
byte
✘
byte[]
≡
double
✘
float
✘
int
✘
int[]
✔
list
✔
long
✘
null
short
✘
string
✔
Casts from ↓ to →
DataDouble
bool
✔
byte
✔
byte[]
null
double
≡
float
✔
int
✔
int[]
null
list
null
long
✔
null
short
✔
string
✔
Casts from ↓ to →
DataFloat
bool
✔
byte
✔
byte[]
null
double
✔
float
≡
int
✔
int[]
null
list
null
long
✔
null
short
✔
string
✔
Casts from ↓ to →
DataInt
bool
✔
byte
✔
byte[]
null
double
✔
float
✔
int
≡
int[]
null
list
null
long
✔
null
short
✔
string
✔
Casts from ↓ to →
DataInt[]
bool
✘
byte
✘
byte[]
✔
double
✘
float
✘
int
✘
int[]
≡
list
✔
long
✘
null
short
✘
string
✔
Casts from ↓ to →
DataList
bool
✘
byte
✘
byte[]
✔
double
✘
float
✘
int
✘
int[]
✔
list
≡
long
✘
null
short
✘
string
✔
Casts from ↓ to →
DataLong
bool
✔
byte
✔
byte[]
null
double
✔
float
✔
int
✔
int[]
null
list
null
long
≡
null
short
✔
string
✔
Casts from ↓ to →
DataMap
bool
✘
byte
✘
byte[]
null
double
✘
float
✘
int
✘
int[]
null
list
null
long
✘
≡
short
✘
string
✔
Casts from ↓ to →
DataShort
bool
✔
byte
✔
byte[]
null
double
✔
float
✔
int
✔
int[]
null
list
null
long
✔
null
short
≡
string
✔
Casts from ↓ to →
DataString
bool
✘
byte
✔
byte[]
null
double
✔
float
✔
int
✔
int[]
null
list
null
long
✔
null
short
✔
string
≡