Interface IListTag

All Superinterfaces:
ITag<ArrayList<Tag<?>>>
All Known Implementing Classes:
Tag_List

public interface IListTag extends ITag<ArrayList<Tag<?>>>
Interface for NBT list tags - ordered collections of same-type elements. Lists enforce type homogeneity, meaning all elements must be of the same NBT type. They're perfect for storing arrays of data like inventory items, coordinates, or any sequential information.
Author:
Paul Ferlitz
See Also:
  • Method Details

    • getListTypeID

      int getListTypeID()
      Returns the NBT type ID that all elements in this list must have. Once set, this cannot be changed and all added elements must match this type.
      Returns:
      The required element type ID (0-12)
    • addString

      IListTag addString(String name, String value)
      Adds a string element to this list. Only works if this list stores string tags.
      Parameters:
      name - The element name
      value - The String value to store
      Returns:
      This list for fluent method chaining
      Throws:
      IllegalArgumentException - if this list doesn't store string tags
    • addInt

      IListTag addInt(String name, int value)
      Adds an integer element to this list. Only works if this list stores integer tags.
      Parameters:
      name - The element name
      value - The Integer value to store
      Returns:
      This list for fluent method chaining
      Throws:
      IllegalArgumentException - if this list doesn't store integer tags
    • addDouble

      IListTag addDouble(String name, double value)
      Adds a double-precision floating point element to this list. Only works if this list stores double tags.
      Parameters:
      name - The element name
      value - The Double value to store
      Returns:
      This list for fluent method chaining
      Throws:
      IllegalArgumentException - if this list doesn't store double tags
    • addCompound

      IListTag addCompound(String name)
      Adds an empty compound element to this list. Only works if this list stores compound tags.
      Parameters:
      name - The element name
      Returns:
      This list for fluent method chaining
      Throws:
      IllegalArgumentException - if this list doesn't store compound tags
    • addFloat

      IListTag addFloat(String name, float value)
      Adds a float element to this list. Only works if this list stores float tags.
      Parameters:
      name - The element name
      value - The Float value to store
      Returns:
      This list for fluent method chaining
      Throws:
      IllegalArgumentException - if this list doesn't store float tags
    • addByte

      IListTag addByte(String name, byte value)
      Adds a byte element to this list. Only works if this list stores byte tags.
      Parameters:
      name - The element name
      value - The Byte value to store
      Returns:
      This list for fluent method chaining
      Throws:
      IllegalArgumentException - if this list doesn't store byte tags
    • addShort

      IListTag addShort(String name, short value)
      Adds a short element to this list. Only works if this list stores short tags.
      Parameters:
      name - The element name
      value - The Short value to store
      Returns:
      This list for fluent method chaining
      Throws:
      IllegalArgumentException - if this list doesn't store short tags
    • addLong

      IListTag addLong(String name, long value)
      Adds a long element to this list. Only works if this list stores long tags.
      Parameters:
      name - The element name
      value - The Long value to store
      Returns:
      This list for fluent method chaining
      Throws:
      IllegalArgumentException - if this list doesn't store long tags
    • setString

      IListTag setString(int index, String name, String value)
      Updates an element at the specified index with a new string value. Only works if this list stores string tags.
      Parameters:
      index - The index to update
      name - The new element name
      value - The new String value
      Returns:
      This list for fluent method chaining
      Throws:
      IllegalArgumentException - if this list doesn't store string tags
      IndexOutOfBoundsException - if index is invalid
    • setInt

      IListTag setInt(int index, String name, int value)
      Updates an element at the specified index with a new integer value. Only works if this list stores integer tags.
      Parameters:
      index - The index to update
      name - The new element name
      value - The new Integer value
      Returns:
      This list for fluent method chaining
      Throws:
      IllegalArgumentException - if this list doesn't store integer tags
      IndexOutOfBoundsException - if index is invalid
    • setDouble

      IListTag setDouble(int index, String name, double value)
      Updates an element at the specified index with a new double value. Only works if this list stores double tags.
      Parameters:
      index - The index to update
      name - The new element name
      value - The new Double value
      Returns:
      This list for fluent method chaining
      Throws:
      IllegalArgumentException - if this list doesn't store double tags
      IndexOutOfBoundsException - if index is invalid
    • setCompound

      IListTag setCompound(int index, String name)
      Updates an element at the specified index with a new compound. Only works if this list stores compound tags.
      Parameters:
      index - The index to update
      name - The new element name
      Returns:
      This list for fluent method chaining
      Throws:
      IllegalArgumentException - if this list doesn't store compound tags
      IndexOutOfBoundsException - if index is invalid
    • setFloat

      IListTag setFloat(int index, String name, float value)
      Updates an element at the specified index with a new float value. Only works if this list stores float tags.
      Parameters:
      index - The index to update
      name - The new element name
      value - The new Float value
      Returns:
      This list for fluent method chaining
      Throws:
      IllegalArgumentException - if this list doesn't store float tags
      IndexOutOfBoundsException - if index is invalid
    • setByte

      IListTag setByte(int index, String name, byte value)
      Updates an element at the specified index with a new byte value. Only works if this list stores byte tags.
      Parameters:
      index - The index to update
      name - The new element name
      value - The new Byte value
      Returns:
      This list for fluent method chaining
      Throws:
      IllegalArgumentException - if this list doesn't store byte tags
      IndexOutOfBoundsException - if index is invalid
    • setShort

      IListTag setShort(int index, String name, short value)
      Updates an element at the specified index with a new short value. Only works if this list stores short tags.
      Parameters:
      index - The index to update
      name - The new element name
      value - The new Short value
      Returns:
      This list for fluent method chaining
      Throws:
      IllegalArgumentException - if this list doesn't store short tags
      IndexOutOfBoundsException - if index is invalid
    • setLong

      IListTag setLong(int index, String name, long value)
      Updates an element at the specified index with a new long value. Only works if this list stores long tags.
      Parameters:
      index - The index to update
      name - The new element name
      value - The new Long value
      Returns:
      This list for fluent method chaining
      Throws:
      IllegalArgumentException - if this list doesn't store long tags
      IndexOutOfBoundsException - if index is invalid
    • setTag

      IListTag setTag(int index, ITag<?> tag)
      Replaces an element at the specified index with a new tag.
      Parameters:
      index - The index to update
      tag - The new tag to set
      Returns:
      This list for fluent method chaining
      Throws:
      IllegalArgumentException - if tag type doesn't match list type
      IndexOutOfBoundsException - if index is invalid
    • removeAt

      IListTag removeAt(int index)
      Removes an element at the specified index.
      Parameters:
      index - The index to remove
      Returns:
      This list for fluent method chaining
      Throws:
      IndexOutOfBoundsException - if index is invalid
    • remove

      IListTag remove(ITag<?> tag)
      Removes the first element that matches the given tag.
      Parameters:
      tag - The tag to remove
      Returns:
      This list for fluent method chaining
    • clear

      IListTag clear()
      Removes all elements from this list.
      Returns:
      This list for fluent method chaining
    • get

      ITag<?> get(int index)
      Gets the element at the specified index.
      Parameters:
      index - The index to retrieve
      Returns:
      The element at the specified index
      Throws:
      IndexOutOfBoundsException - if index is invalid
    • size

      int size()
      Gets the number of elements in this list.
      Returns:
      The number of elements
    • isEmpty

      boolean isEmpty()
      Checks if this list is empty (has no elements).
      Returns:
      true if empty, false otherwise