Interface IData

All Superinterfaces:
Comparable<IData>, Iterable<IData>
All Known Implementing Classes:
BoolData, ByteArrayData, ByteData, DoubleData, EmptyData, FloatData, IntArrayData, IntData, ListData, LongArrayData, LongData, MapData, ShortData, StringData

@ZenRegister(loaders={"crafttweaker","tags"}) public interface IData extends Comparable<IData>, Iterable<IData>
DocParam:
this (1 as IData)
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
    Used to specify what "type" of IData this is.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    accept(DataVisitor<T> visitor)
     
    default IData
    add(IData other)
    Adds the given IData to this IData.
    default IData
    and(IData other)
    Applies a bitwise AND (invalid input: '&') operation to this IData and the other IData
    default boolean
    Casts this IData to a boolean.
    default @org.openzen.zencode.java.ZenCodeType.Unsigned byte
    Casts this IData to a byte.
    default byte[]
    Casts this IData to a byte array.
    default double
    Casts this IData to a double.
    default float
    Casts this IData to a float.
    default int
    Casts this IData to an int.
    default int[]
    Casts this IData to an int array.
    default List<IData>
    Casts this IData to a list.
    default long
    Casts this IData to a long.
    default long[]
    Casts this IData to a long array.
    default Map<String,IData>
    Casts this IData to a map.
    default short
    Casts this IData to a short.
    default String
    Gets an escaped string version of this IData, quotes are included in the output
    default IData
    cat(IData other)
    Concatenates the given IData to this IData.
    default int
    compareTo(@NotNull IData other)
    Compares this IData to the other IData
    default boolean
    contains(IData other)
    Checks if this IData contains the other IData
    default boolean
    containsList(List<IData> dataValues)
     
     
     
    default IData
    div(IData other)
    Divides the given IData from this IData.
    default boolean
    equalTo(IData other)
    Checks if this IData is equal to the other IData.
    default String
    Gets the literal string version of this IData.
    default IData
    getAt(int index)
    Gets the data at the given index.
    default IData
    Gets the data at the given key.
    default byte
    Gets the internal ID of this data.
    net.minecraft.nbt.Tag
    Gets the internal Tag stored in this IData.
    default Set<String>
    Gets the keys of this IData
    Gets the type of this IData.
    default boolean
    Checks if this data is empty.
    default boolean
    Checks if this data supports being cast to a list.
    default boolean
    Checks if this data supports being cast to a map.
    default @NotNull Iterator<IData>
     
    default int
    Gets the length of this IData.
    static IData
    listOf(IData... members)
    Creates a collection of the given IData members.
    default IData
    map(Function<IData,IData> operation)
    Maps this IData to another IData based on the given operation.
    default IData
    merge(IData other)
    Merges the given data with this data.
    default IData
    mod(IData other)
    Applies a modulo operation to this IData against the other IData.
    default IData
    mul(IData other)
    Multiplies the given IData to this IData.
    default IData
    neg()
    Negates this IData.
    default IData
    not()
    Applies a NOT (!) operation to this IData.
    default IData
    or(IData other)
    Applies a bitwise OR (|) operation to this IData and the other IData
    default void
    put(String index, IData value)
    Puts the given value inside this IData at the given index.
    default void
    remove(int index)
    Removes the stored data at the given index.
    default void
    Removes the stored data at the given key.
    default void
    setAt(String name, IData data)
    Sets the given value inside this IData at the given index.
    default IData
    shl(IData other)
    Applies a SHL (invalid input: '<'invalid input: '<') operation to this data by the other data
    default IData
    shr(IData other)
    Applies a SHR (>>) operation to this data by the other data
    default IData
    sub(IData other)
    Subtracts the given IData from this IData.
    default IData
    xor(IData other)
    Applies a bitwise XOR (^) operation to this IData and the other IData

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Method Details

    • listOf

      static IData listOf(IData... members)
      Creates a collection of the given IData members.

      This attempts to give the most accurate type for the given members, for example, if all the members are bytes, then it returns a ByteArrayData. However if the types are mixed or do not have a *ArrayData version, then a ListData is returned.

      Parameters:
      members - The members to put in the list.
      Returns:
      A list of the given members.
      DocParam:
      members 1, 2, 3
    • add

      default IData add(IData other)
      Adds the given IData to this IData.
      Parameters:
      other - the other data to add.
      Returns:
      A new IData after adding the other data.
      DocParam:
      other 2
    • sub

      default IData sub(IData other)
      Subtracts the given IData from this IData.
      Parameters:
      other - the other data to remove.
      Returns:
      A new IData after removing the other data.
      DocParam:
      other 2
    • mul

      default IData mul(IData other)
      Multiplies the given IData to this IData.
      Parameters:
      other - the other data to multiply by.
      Returns:
      A new IData after multiplying the other data.
      DocParam:
      other 2
    • div

      default IData div(IData other)
      Divides the given IData from this IData.
      Parameters:
      other - the other data to divide by.
      Returns:
      A new IData after dividing the other data.
      DocParam:
      other 2
    • mod

      default IData mod(IData other)
      Applies a modulo operation to this IData against the other IData.
      Parameters:
      other - the other data to modulo by.
      Returns:
      A new IData after applying a modulo operation.
      DocParam:
      other 2
    • cat

      default IData cat(IData other)
      Concatenates the given IData to this IData.
      Parameters:
      other - the other data to concatenate.
      Returns:
      A new IData after concatenating the other data.
      DocParam:
      other 2
    • or

      default IData or(IData other)
      Applies a bitwise OR (|) operation to this IData and the other IData
      Parameters:
      other - the other data.
      Returns:
      A new IData after applying a bitwise OR operation.
      DocParam:
      other 2
    • and

      default IData and(IData other)
      Applies a bitwise AND (invalid input: '&') operation to this IData and the other IData
      Parameters:
      other - the other data.
      Returns:
      A new IData after applying a bitwise AND operation.
      DocParam:
      other 2
    • xor

      default IData xor(IData other)
      Applies a bitwise XOR (^) operation to this IData and the other IData
      Parameters:
      other - the other data.
      Returns:
      A new IData after applying a bitwise XOR operation.
      DocParam:
      other 2
    • neg

      default IData neg()
      Negates this IData.
      Returns:
      The negation of this IData.
    • not

      default IData not()
      Applies a NOT (!) operation to this IData.
      Returns:
      The result of the NOT operation.
      DocParam:
      this true
    • put

      default void put(String index, IData value)
      Puts the given value inside this IData at the given index.
      Parameters:
      index - The key to store the data at
      value - The data to store.
      DocParam:
      index "key", value "value", this new MapData()
    • getAt

      default IData getAt(int index)
      Gets the data at the given index.
      Parameters:
      index - The index to get
      Returns:
      The data at the index.
      DocParam:
      index 0, this [1, 2, 3] as IData
    • getAt

      default IData getAt(String key)
      Gets the data at the given key.
      Parameters:
      key - The key to get
      Returns:
      The data at the key.
      DocParam:
      index "key", this {key: "value"}
    • contains

      default boolean contains(IData other)
      Checks if this IData contains the other IData

      For most data types, this will check equality of the data, but for map data, it will check if the other data is a string, and then check if it contains a key with that name

      Parameters:
      other - the other data to check
      Returns:
      true if this data contains the other data.
    • compareTo

      default int compareTo(@NotNull @NotNull IData other)
      Compares this IData to the other IData
      Specified by:
      compareTo in interface Comparable<IData>
      Parameters:
      other - the data to be compared.
      Returns:
      The comparison result.
      DocParam:
      other 5
    • remove

      default void remove(int index)
      Removes the stored data at the given index.
      Parameters:
      index - The index to remove.
      DocParam:
      index 0, this [1, 2, 3] as IData
    • remove

      default void remove(String key)
      Removes the stored data at the given key.
      Parameters:
      key - The key to remove.
      DocParam:
      key "key", this {key: "value"} as IData
    • setAt

      default void setAt(String name, IData data)
      Sets the given value inside this IData at the given index.
      Parameters:
      name - The key to store the data at
      data - The data to store.
      DocParam:
      index "key", value "value", this new MapData()
    • equalTo

      default boolean equalTo(IData other)
      Checks if this IData is equal to the other IData.
      Parameters:
      other - The data to check equality of.
      Returns:
      True if equal, false otherwise.
    • shl

      default IData shl(IData other)
      Applies a SHL (invalid input: '<'invalid input: '<') operation to this data by the other data
      Parameters:
      other - The data to SHL by.
      Returns:
      The result of the SHL operation.
      DocParam:
      other 2
    • shr

      default IData shr(IData other)
      Applies a SHR (>>) operation to this data by the other data
      Parameters:
      other - The data to SHR by.
      Returns:
      The result of the SHR operation.
      DocParam:
      other 2
    • asBool

      default boolean asBool()
      Casts this IData to a boolean.
      Returns:
      this data as a bool
    • asByte

      default @org.openzen.zencode.java.ZenCodeType.Unsigned byte asByte()
      Casts this IData to a byte.
      Returns:
      this data as a byte
    • asShort

      default short asShort()
      Casts this IData to a short.
      Returns:
      this data as a short
    • asInt

      default int asInt()
      Casts this IData to an int.
      Returns:
      this data as an int
    • asLong

      default long asLong()
      Casts this IData to a long.
      Returns:
      this data as a long
    • asFloat

      default float asFloat()
      Casts this IData to a float.
      Returns:
      this data as a float
    • asDouble

      default double asDouble()
      Casts this IData to a double.
      Returns:
      this data as a double
    • asString

      default String asString()
      Gets an escaped string version of this IData, quotes are included in the output

      E.G println(("hello" as IData).asString()) prints "hello"

      Returns:
      The escaped string version of this IData.
    • getAsString

      default String getAsString()
      Gets the literal string version of this IData.

      E.G println(("hello" as IData).getAsString()) prints hello

      Returns:
      The literal string version of this IData.
    • asList

      default List<IData> asList()
      Casts this IData to a list.
      Returns:
      this data as a list
    • asMap

      default Map<String,IData> asMap()
      Casts this IData to a map.
      Returns:
      this data as a map
    • asByteArray

      default byte[] asByteArray()
      Casts this IData to a byte array.
      Returns:
      this data as a byte array
    • asIntArray

      default int[] asIntArray()
      Casts this IData to an int array.
      Returns:
      this data as an int array
    • asLongArray

      default long[] asLongArray()
      Casts this IData to a long array.
      Returns:
      this data as a long array
    • length

      default int length()
      Gets the length of this IData.
      Returns:
      The length of this IData.
    • getKeys

      default Set<String> getKeys()
      Gets the keys of this IData
      Returns:
      The keys of this IData.
    • iterator

      @NotNull default @NotNull Iterator<IData> iterator()
      Specified by:
      iterator in interface Iterable<IData>
    • merge

      default IData merge(IData other)
      Merges the given data with this data.
      Parameters:
      other - the data to merge
      Returns:
      the result of merging the datas.
      DocParam:
      this {}
    • isEmpty

      default boolean isEmpty()
      Checks if this data is empty.
      Returns:
      True if empty.
    • getId

      default byte getId()
      Gets the internal ID of this data.
      Returns:
      the intenral ID of this data.
    • getInternal

      net.minecraft.nbt.Tag getInternal()
      Gets the internal Tag stored in this IData.
      Returns:
      the vanilla Tag that this IData represents.
    • copy

      IData copy()
    • copyInternal

      IData copyInternal()
    • accept

      <T> T accept(DataVisitor<T> visitor)
    • map

      default IData map(Function<IData,IData> operation)
      Maps this IData to another IData based on the given operation.
      Parameters:
      operation - The operation to apply to this IData
      Returns:
      A new IData from the operation
      DocParam:
      operation (data) => 3
    • getType

      IData.Type getType()
      Gets the type of this IData.
      Returns:
      The type of this IData.
    • isListable

      @Internal default boolean isListable()
      Checks if this data supports being cast to a list.
      Returns:
      True if it can be cast to a list, false otherwise.
    • isMappable

      @Internal default boolean isMappable()
      Checks if this data supports being cast to a map.
      Returns:
      True if it can be cast to a map, false otherwise.
    • containsList

      default boolean containsList(List<IData> dataValues)