Class ListData

java.lang.Object
com.blamejared.crafttweaker.api.data.ListData
All Implemented Interfaces:
ICollectionData, IData

@ZenRegister public class ListData extends Object implements ICollectionData
DocParam:
this ["Hello", "World", "!"]
  • Constructor Details

    • ListData

      public ListData(net.minecraft.nbt.ListTag internal)
    • ListData

      public ListData()
    • ListData

      public ListData(List<IData> list)
    • ListData

      public ListData(IData... array)
  • Method Details

    • create

      public static ListData create()
    • setAt

      public IData setAt(int index, IData value)
      Description copied from interface: ICollectionData
      Sets the item at the provided index to the given value
      Specified by:
      setAt in interface ICollectionData
      Parameters:
      index - The index to set (0-based)
      value - The new Value
      Returns:
      The replaced value
    • add

      public void add(int index, IData value)
      Specified by:
      add in interface ICollectionData
      Parameters:
      index - The index to add to. Subsequent items will be moved one index higher
      value - The value to add to the list
    • add

      public void add(IData value)
      Specified by:
      add in interface ICollectionData
      Parameters:
      value - The value to add to the list
    • remove

      public IData remove(int index)
      Description copied from interface: ICollectionData
      Removes the IData stored at the given index.
      Specified by:
      remove in interface ICollectionData
      Parameters:
      index - The index (0-based)
      Returns:
      The IData that was removed
    • getAt

      public IData getAt(int index)
      Description copied from interface: ICollectionData
      Retrieves the IData stored at the given index.
      Specified by:
      getAt in interface ICollectionData
      Parameters:
      index - The index (0-based)
      Returns:
      The IData
    • getData

      public <T extends IData> T getData(Class<T> clazz, int index)
    • size

      public int size()
      Specified by:
      size in interface ICollectionData
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface ICollectionData
    • clear

      public void clear()
      Description copied from interface: ICollectionData
      Removes every element in the list
      Specified by:
      clear in interface ICollectionData
    • copy

      public ListData copy()
      Description copied from interface: IData
      Makes a copy of this IData. IData is immutable by default, use this to create a proper copy of the object.
      Specified by:
      copy in interface ICollectionData
      Specified by:
      copy in interface IData
      Returns:
      a copy of this IData.
    • copyInternal

      public ListData copyInternal()
      Description copied from interface: IData
      Makes a copy of this IData with a copy of the internal INBT object.
      Specified by:
      copyInternal in interface ICollectionData
      Specified by:
      copyInternal in interface IData
      Returns:
      a copy of this IData with a copy of the internal INBT object.
    • getInternal

      public net.minecraft.nbt.ListTag getInternal()
      Description copied from interface: IData
      Gets the internal INBT stored in this IData.
      Specified by:
      getInternal in interface IData
      Returns:
      the vanilla INBT tag that this IData represents.
    • asList

      public List<IData> asList()
      Description copied from interface: IData
      Gets a List representation of this IData, returns null on anything but ListData.
      Specified by:
      asList in interface IData
      Returns:
      null if this IData is not a list.
    • contains

      public boolean contains(IData data)
      Description copied from interface: IData
      Checks if this IData contains another IData, mainly used in subclasses of ICollectionData, is the same as an equals check on other IData types
      Specified by:
      contains in interface IData
      Parameters:
      data - data to check if it is contained
      Returns:
      true if the given IData is contained in this IData
    • castToList

      public List<IData> castToList()
    • getType

      public IData.Type getType()
      Description copied from interface: IData
      Gets the type of this IData.
      Specified by:
      getType in interface IData
      Returns:
      The type of this IData.
    • accept

      public <T> T accept(DataVisitor<T> visitor)
      Specified by:
      accept in interface IData
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object