IData #数据
Link to 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).
导入相关包
Link to 导入相关包
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
Link to overview
Binary Operators | + | - | * | / | % | & | | | ^ | in | == | <, >, <=, >= |
---|---|---|---|---|---|---|---|---|---|---|---|
Binary Operators DataBool | + | - | * | / | % | & | | | ^ | in | == | <, >, <=, >= |
Binary Operators DataByte | + | - | * | / | % | & | | | ^ | in | == | <, >, <=, >= |
Binary Operators DataByte[] | + | - | * | / | % | & | | | ^ | in | == | <, >, <=, >= |
Binary Operators DataDouble | + | - | * | / | % | & | | | ^ | in | == | <, >, <=, >= |
Binary Operators DataFloat | + | - | * | / | % | & | | | ^ | in | == | <, >, <=, >= |
Binary Operators DataInt | + | - | * | / | % | & | | | ^ | in | == | <, >, <=, >= |
Binary Operators DataInt[] | + | - | * | / | % | & | | | ^ | in | == | <, >, <=, >= |
Binary Operators DataList | + | - | * | / | % | & | | | ^ | in | == | <, >, <=, >= |
Binary Operators DataLong | + | - | * | / | % | & | | | ^ | in | == | <, >, <=, >= |
Binary Operators DataMap | + | - | * | / | % | & | | | ^ | in | == | <, >, <=, >= |
Binary Operators DataShort | + | - | * | / | % | & | | | ^ | in | == | <, >, <=, >= |
Binary Operators DataString | + | - | * | / | % | & | | | ^ | in | == | <, >, <=, >= |
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 0 | .immutable | .update(v) |
Index and Members DataByte | [i] | [i]=v | .member | .member=v | .length 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 0 | .immutable | .update(v) |
Index and Members DataFloat | [i] | [i]=v | .member | .member=v | .length 0 | .immutable | .update(v) |
Index and Members DataInt | [i] | [i]=v | .member | .member=v | .length 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 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 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 → | bool | byte | byte[] | double | float | int | 整型[] | 列表 | long | Map | short | string |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Casts from ↓ to → DataBool | bool ≡ | byte ✔ | byte[] null | double ✔ | float ✔ | int ✔ | 整型[] null | 列表 null | long ✔ | null | short ✔ | string ✔ |
Casts from ↓ to → DataByte | bool ✔ | byte ≡ | byte[] null | double ✔ | float ✔ | int ✔ | 整型[] null | 列表 null | long ✔ | null | short ✔ | string ✔ |
Casts from ↓ to → DataByte[] | bool ✘ | byte ✘ | byte[] ≡ | double ✘ | float ✘ | int ✘ | 整型[] ✔ | 列表 ✔ | long ✘ | null | short ✘ | string ✔ |
Casts from ↓ to → DataDouble | bool ✔ | byte ✔ | byte[] null | double ≡ | float ✔ | int ✔ | 整型[] null | 列表 null | long ✔ | null | short ✔ | string ✔ |
Casts from ↓ to → DataFloat | bool ✔ | byte ✔ | byte[] null | double ✔ | float ≡ | int ✔ | 整型[] null | 列表 null | long ✔ | null | short ✔ | string ✔ |
Casts from ↓ to → DataInt | bool ✔ | byte ✔ | byte[] null | double ✔ | float ✔ | int ≡ | 整型[] null | 列表 null | long ✔ | null | short ✔ | string ✔ |
Casts from ↓ to → DataInt[] | bool ✘ | byte ✘ | byte[] ✔ | double ✘ | float ✘ | int ✘ | 整型[] ≡ | 列表 ✔ | long ✘ | null | short ✘ | string ✔ |
Casts from ↓ to → DataList | bool ✘ | byte ✘ | byte[] ✔ | double ✘ | float ✘ | int ✘ | 整型[] ✔ | 列表 ≡ | long ✘ | null | short ✘ | string ✔ |
Casts from ↓ to → DataLong | bool ✔ | byte ✔ | byte[] null | double ✔ | float ✔ | int ✔ | 整型[] null | 列表 null | long ≡ | null | short ✔ | string ✔ |
Casts from ↓ to → DataMap | bool ✘ | byte ✘ | byte[] null | double ✘ | float ✘ | int ✘ | 整型[] null | 列表 null | long ✘ | ≡ | short ✘ | string ✔ |
Casts from ↓ to → DataShort | bool ✔ | byte ✔ | byte[] null | double ✔ | float ✔ | int ✔ | 整型[] null | 列表 null | long ✔ | null | short ≡ | string ✔ |
Casts from ↓ to → DataString | bool ✘ | byte ✔ | byte[] null | double ✔ | float ✔ | int ✔ | 整型[] null | 列表 null | long ✔ | null | short ✔ | string ≡ |