Module syntaxnbt

Class TagList<T extends Tag<?>>

java.lang.Object
at.syntaxerror.syntaxnbt.tag.Tag<List<T>>
at.syntaxerror.syntaxnbt.tag.TagList<T>
Type Parameters:
T - type of the elements stored in this tag
All Implemented Interfaces:
Iterable<T>

public class TagList<T extends Tag<?>> extends Tag<List<T>> implements Iterable<T>
A list of nameless tags, all of the same type. The list is prefixed with the Type ID of the items it contains (thus 1 byte), and the length of the list as a signed integer (a further 4 bytes). If the length of the list is 0 or negative, the type may be 0 (TAG_End) but otherwise it must be any other type. (The notchian implementation uses TAG_End in that situation, but another reference implementation by Mojang uses 1 instead; parsers should accept any type if the length is <= 0).
Author:
SyntaxError404
  • Constructor Details

    • TagList

      public TagList(Class<T> typeClass)
      Constructs an empty list of the specified type
      Parameters:
      typeClass - type of elements in this list
    • TagList

      public TagList(Class<T> typeClass, Collection<T> elements)
      Constructs a list of the specified type
      Parameters:
      typeClass - type of elements in this list
      elements - the collection whose elements are to be placed into this list
  • Method Details

    • emptyList

      public static TagList<Tag<?>> emptyList()
      Constructs an empty list without a specified type. The type is determined when an element is added or the list is casted to a specific type.
      Returns:
      the empty list
    • get

      public T get(int index)
      Returns the element at the specified position in this list
      Parameters:
      index - index of the element to be returned
      Returns:
      the element at the specified position in this list
    • getByte

      public byte getByte(int index)
      Returns the element at the specified position in this list
      Parameters:
      index - index of the element to be returned
      Returns:
      the element at the specified position in this list
    • getShort

      public short getShort(int index)
      Returns the element at the specified position in this list
      Parameters:
      index - index of the element to be returned
      Returns:
      the element at the specified position in this list
    • getInt

      public int getInt(int index)
      Returns the element at the specified position in this list
      Parameters:
      index - index of the element to be returned
      Returns:
      the element at the specified position in this list
    • getLong

      public long getLong(int index)
      Returns the element at the specified position in this list
      Parameters:
      index - index of the element to be returned
      Returns:
      the element at the specified position in this list
    • getFloat

      public float getFloat(int index)
      Returns the element at the specified position in this list
      Parameters:
      index - index of the element to be returned
      Returns:
      the element at the specified position in this list
    • getDouble

      public double getDouble(int index)
      Returns the element at the specified position in this list
      Parameters:
      index - index of the element to be returned
      Returns:
      the element at the specified position in this list
    • getByteArray

      public byte[] getByteArray(int index)
      Returns the element at the specified position in this list
      Parameters:
      index - index of the element to be returned
      Returns:
      the element at the specified position in this list
    • getIntArray

      public int[] getIntArray(int index)
      Returns the element at the specified position in this list
      Parameters:
      index - index of the element to be returned
      Returns:
      the element at the specified position in this list
    • getLongArray

      public long[] getLongArray(int index)
      Returns the element at the specified position in this list
      Parameters:
      index - index of the element to be returned
      Returns:
      the element at the specified position in this list
    • getString

      public String getString(int index)
      Returns the element at the specified position in this list
      Parameters:
      index - index of the element to be returned
      Returns:
      the element at the specified position in this list
    • getByteTag

      public TagByte getByteTag(int index)
      Returns the element at the specified position in this list
      Parameters:
      index - index of the element to be returned
      Returns:
      the element at the specified position in this list
    • getShortTag

      public TagShort getShortTag(int index)
      Returns the element at the specified position in this list
      Parameters:
      index - index of the element to be returned
      Returns:
      the element at the specified position in this list
    • getIntTag

      public TagInt getIntTag(int index)
      Returns the element at the specified position in this list
      Parameters:
      index - index of the element to be returned
      Returns:
      the element at the specified position in this list
    • getLongTag

      public TagLong getLongTag(int index)
      Returns the element at the specified position in this list
      Parameters:
      index - index of the element to be returned
      Returns:
      the element at the specified position in this list
    • getFloatTag

      public TagFloat getFloatTag(int index)
      Returns the element at the specified position in this list
      Parameters:
      index - index of the element to be returned
      Returns:
      the element at the specified position in this list
    • getDoubleTag

      public TagDouble getDoubleTag(int index)
      Returns the element at the specified position in this list
      Parameters:
      index - index of the element to be returned
      Returns:
      the element at the specified position in this list
    • getByteArrayTag

      public TagByteArray getByteArrayTag(int index)
      Returns the element at the specified position in this list
      Parameters:
      index - index of the element to be returned
      Returns:
      the element at the specified position in this list
    • getIntArrayTag

      public TagIntArray getIntArrayTag(int index)
      Returns the element at the specified position in this list
      Parameters:
      index - index of the element to be returned
      Returns:
      the element at the specified position in this list
    • getLongArrayTag

      public TagLongArray getLongArrayTag(int index)
      Returns the element at the specified position in this list
      Parameters:
      index - index of the element to be returned
      Returns:
      the element at the specified position in this list
    • getStringTag

      public TagString getStringTag(int index)
      Returns the element at the specified position in this list
      Parameters:
      index - index of the element to be returned
      Returns:
      the element at the specified position in this list
    • getCompound

      public TagCompound getCompound(int index)
      Returns the element at the specified position in this list
      Parameters:
      index - index of the element to be returned
      Returns:
      the element at the specified position in this list
    • getList

      public TagList<?> getList(int index)
      Returns the element at the specified position in this list
      Parameters:
      index - index of the element to be returned
      Returns:
      the element at the specified position in this list
    • add

      public TagList<T> add(T value)
      Add an element to the list
      Parameters:
      value - element to be added
      Returns:
      this list
    • addByte

      public TagList<T> addByte(byte value)
      Add an element to the list
      Parameters:
      value - element to be added
      Returns:
      this list
    • addShort

      public TagList<T> addShort(short value)
      Add an element to the list
      Parameters:
      value - element to be added
      Returns:
      this list
    • addInt

      public TagList<T> addInt(int value)
      Add an element to the list
      Parameters:
      value - element to be added
      Returns:
      this list
    • addLong

      public TagList<T> addLong(long value)
      Add an element to the list
      Parameters:
      value - element to be added
      Returns:
      this list
    • addFloat

      public TagList<T> addFloat(float value)
      Add an element to the list
      Parameters:
      value - element to be added
      Returns:
      this list
    • addDouble

      public TagList<T> addDouble(double value)
      Add an element to the list
      Parameters:
      value - element to be added
      Returns:
      this list
    • addByteArray

      public TagList<T> addByteArray(byte[] value)
      Add an element to the list
      Parameters:
      value - element to be added
      Returns:
      this list
    • addIntArray

      public TagList<T> addIntArray(int[] value)
      Add an element to the list
      Parameters:
      value - element to be added
      Returns:
      this list
    • addLongArray

      public TagList<T> addLongArray(long[] value)
      Add an element to the list
      Parameters:
      value - element to be added
      Returns:
      this list
    • addString

      public TagList<T> addString(String value)
      Add an element to the list
      Parameters:
      value - element to be added
      Returns:
      this list
    • addByteTag

      public TagList<T> addByteTag(TagByte value)
      Add an element to the list
      Parameters:
      value - element to be added
      Returns:
      this list
    • addShortTag

      public TagList<T> addShortTag(TagShort value)
      Add an element to the list
      Parameters:
      value - element to be added
      Returns:
      this list
    • addIntTag

      public TagList<T> addIntTag(TagInt value)
      Add an element to the list
      Parameters:
      value - element to be added
      Returns:
      this list
    • addLongTag

      public TagList<T> addLongTag(TagLong value)
      Add an element to the list
      Parameters:
      value - element to be added
      Returns:
      this list
    • addFloatTag

      public TagList<T> addFloatTag(TagFloat value)
      Add an element to the list
      Parameters:
      value - element to be added
      Returns:
      this list
    • addDoubleTag

      public TagList<T> addDoubleTag(TagDouble value)
      Add an element to the list
      Parameters:
      value - element to be added
      Returns:
      this list
    • addByteArrayTag

      public TagList<T> addByteArrayTag(TagByteArray value)
      Add an element to the list
      Parameters:
      value - element to be added
      Returns:
      this list
    • addIntArrayTag

      public TagList<T> addIntArrayTag(TagIntArray value)
      Add an element to the list
      Parameters:
      value - element to be added
      Returns:
      this list
    • addLongArrayTag

      public TagList<T> addLongArrayTag(TagLongArray value)
      Add an element to the list
      Parameters:
      value - element to be added
      Returns:
      this list
    • addStringTag

      public TagList<T> addStringTag(TagString value)
      Add an element to the list
      Parameters:
      value - element to be added
      Returns:
      this list
    • addCompound

      public TagList<T> addCompound(TagCompound value)
      Add an element to the list
      Parameters:
      value - element to be added
      Returns:
      this list
    • addList

      public TagList<T> addList(TagList<?> value)
      Add an element to the list
      Parameters:
      value - element to be added
      Returns:
      this list
    • add

      public TagList<T> add(int index, T value)
      Inserts an element at the specified position in the list
      Parameters:
      index - index at which the specified element is to be inserted
      value - element to be inserted
      Returns:
      this list
    • addByte

      public TagList<T> addByte(int index, byte value)
      Inserts an element at the specified position in the list
      Parameters:
      index - index at which the specified element is to be inserted
      value - element to be inserted
      Returns:
      this list
    • addShort

      public TagList<T> addShort(int index, short value)
      Inserts an element at the specified position in the list
      Parameters:
      index - index at which the specified element is to be inserted
      value - element to be inserted
      Returns:
      this list
    • addInt

      public TagList<T> addInt(int index, int value)
      Inserts an element at the specified position in the list
      Parameters:
      index - index at which the specified element is to be inserted
      value - element to be inserted
      Returns:
      this list
    • addLong

      public TagList<T> addLong(int index, long value)
      Inserts an element at the specified position in the list
      Parameters:
      index - index at which the specified element is to be inserted
      value - element to be inserted
      Returns:
      this list
    • addFloat

      public TagList<T> addFloat(int index, float value)
      Inserts an element at the specified position in the list
      Parameters:
      index - index at which the specified element is to be inserted
      value - element to be inserted
      Returns:
      this list
    • addDouble

      public TagList<T> addDouble(int index, double value)
      Inserts an element at the specified position in the list
      Parameters:
      index - index at which the specified element is to be inserted
      value - element to be inserted
      Returns:
      this list
    • addByteArray

      public TagList<T> addByteArray(int index, byte[] value)
      Inserts an element at the specified position in the list
      Parameters:
      index - index at which the specified element is to be inserted
      value - element to be inserted
      Returns:
      this list
    • addIntArray

      public TagList<T> addIntArray(int index, int[] value)
      Inserts an element at the specified position in the list
      Parameters:
      index - index at which the specified element is to be inserted
      value - element to be inserted
      Returns:
      this list
    • addLongArray

      public TagList<T> addLongArray(int index, long[] value)
      Inserts an element at the specified position in the list
      Parameters:
      index - index at which the specified element is to be inserted
      value - element to be inserted
      Returns:
      this list
    • addString

      public TagList<T> addString(int index, String value)
      Inserts an element at the specified position in the list
      Parameters:
      index - index at which the specified element is to be inserted
      value - element to be inserted
      Returns:
      this list
    • addByteTag

      public TagList<T> addByteTag(int index, TagByte value)
      Inserts an element at the specified position in the list
      Parameters:
      index - index at which the specified element is to be inserted
      value - element to be inserted
      Returns:
      this list
    • addShortTag

      public TagList<T> addShortTag(int index, TagShort value)
      Inserts an element at the specified position in the list
      Parameters:
      index - index at which the specified element is to be inserted
      value - element to be inserted
      Returns:
      this list
    • addIntTag

      public TagList<T> addIntTag(int index, TagInt value)
      Inserts an element at the specified position in the list
      Parameters:
      index - index at which the specified element is to be inserted
      value - element to be inserted
      Returns:
      this list
    • addLongTag

      public TagList<T> addLongTag(int index, TagLong value)
      Inserts an element at the specified position in the list
      Parameters:
      index - index at which the specified element is to be inserted
      value - element to be inserted
      Returns:
      this list
    • addFloatTag

      public TagList<T> addFloatTag(int index, TagFloat value)
      Inserts an element at the specified position in the list
      Parameters:
      index - index at which the specified element is to be inserted
      value - element to be inserted
      Returns:
      this list
    • addDoubleTag

      public TagList<T> addDoubleTag(int index, TagDouble value)
      Inserts an element at the specified position in the list
      Parameters:
      index - index at which the specified element is to be inserted
      value - element to be inserted
      Returns:
      this list
    • addByteArrayTag

      public TagList<T> addByteArrayTag(int index, TagByteArray value)
      Inserts an element at the specified position in the list
      Parameters:
      index - index at which the specified element is to be inserted
      value - element to be inserted
      Returns:
      this list
    • addIntArrayTag

      public TagList<T> addIntArrayTag(int index, TagIntArray value)
      Inserts an element at the specified position in the list
      Parameters:
      index - index at which the specified element is to be inserted
      value - element to be inserted
      Returns:
      this list
    • addLongArrayTag

      public TagList<T> addLongArrayTag(int index, TagLongArray value)
      Inserts an element at the specified position in the list
      Parameters:
      index - index at which the specified element is to be inserted
      value - element to be inserted
      Returns:
      this list
    • addStringTag

      public TagList<T> addStringTag(int index, TagString value)
      Inserts an element at the specified position in the list
      Parameters:
      index - index at which the specified element is to be inserted
      value - element to be inserted
      Returns:
      this list
    • addCompound

      public TagList<T> addCompound(int index, TagCompound value)
      Inserts an element at the specified position in the list
      Parameters:
      index - index at which the specified element is to be inserted
      value - element to be inserted
      Returns:
      this list
    • addList

      public TagList<T> addList(int index, TagList<?> value)
      Inserts an element at the specified position in the list
      Parameters:
      index - index at which the specified element is to be inserted
      value - element to be inserted
      Returns:
      this list
    • set

      public TagList<T> set(int index, T value)
      Replaces an element at the specified position in the list
      Parameters:
      index - index of the element to replace
      value - element to be stored at the specified position
      Returns:
      this list
    • setByte

      public TagList<T> setByte(int index, byte value)
      Replaces an element at the specified position in the list
      Parameters:
      index - index of the element to replace
      value - element to be stored at the specified position
      Returns:
      this list
    • setShort

      public TagList<T> setShort(int index, short value)
      Replaces an element at the specified position in the list
      Parameters:
      index - index of the element to replace
      value - element to be stored at the specified position
      Returns:
      this list
    • setInt

      public TagList<T> setInt(int index, int value)
      Replaces an element at the specified position in the list
      Parameters:
      index - index of the element to replace
      value - element to be stored at the specified position
      Returns:
      this list
    • setLong

      public TagList<T> setLong(int index, long value)
      Replaces an element at the specified position in the list
      Parameters:
      index - index of the element to replace
      value - element to be stored at the specified position
      Returns:
      this list
    • setFloat

      public TagList<T> setFloat(int index, float value)
      Replaces an element at the specified position in the list
      Parameters:
      index - index of the element to replace
      value - element to be stored at the specified position
      Returns:
      this list
    • setDouble

      public TagList<T> setDouble(int index, double value)
      Replaces an element at the specified position in the list
      Parameters:
      index - index of the element to replace
      value - element to be stored at the specified position
      Returns:
      this list
    • setByteArray

      public TagList<T> setByteArray(int index, byte[] value)
      Replaces an element at the specified position in the list
      Parameters:
      index - index of the element to replace
      value - element to be stored at the specified position
      Returns:
      this list
    • setIntArray

      public TagList<T> setIntArray(int index, int[] value)
      Replaces an element at the specified position in the list
      Parameters:
      index - index of the element to replace
      value - element to be stored at the specified position
      Returns:
      this list
    • setLongArray

      public TagList<T> setLongArray(int index, long[] value)
      Replaces an element at the specified position in the list
      Parameters:
      index - index of the element to replace
      value - element to be stored at the specified position
      Returns:
      this list
    • setString

      public TagList<T> setString(int index, String value)
      Replaces an element at the specified position in the list
      Parameters:
      index - index of the element to replace
      value - element to be stored at the specified position
      Returns:
      this list
    • setByteTag

      public TagList<T> setByteTag(int index, TagByte value)
      Replaces an element at the specified position in the list
      Parameters:
      index - index of the element to replace
      value - element to be stored at the specified position
      Returns:
      this list
    • setShortTag

      public TagList<T> setShortTag(int index, TagShort value)
      Replaces an element at the specified position in the list
      Parameters:
      index - index of the element to replace
      value - element to be stored at the specified position
      Returns:
      this list
    • setIntTag

      public TagList<T> setIntTag(int index, TagInt value)
      Replaces an element at the specified position in the list
      Parameters:
      index - index of the element to replace
      value - element to be stored at the specified position
      Returns:
      this list
    • setLongTag

      public TagList<T> setLongTag(int index, TagLong value)
      Replaces an element at the specified position in the list
      Parameters:
      index - index of the element to replace
      value - element to be stored at the specified position
      Returns:
      this list
    • setFloatTag

      public TagList<T> setFloatTag(int index, TagFloat value)
      Replaces an element at the specified position in the list
      Parameters:
      index - index of the element to replace
      value - element to be stored at the specified position
      Returns:
      this list
    • setDoubleTag

      public TagList<T> setDoubleTag(int index, TagDouble value)
      Replaces an element at the specified position in the list
      Parameters:
      index - index of the element to replace
      value - element to be stored at the specified position
      Returns:
      this list
    • setByteArrayTag

      public TagList<T> setByteArrayTag(int index, TagByteArray value)
      Replaces an element at the specified position in the list
      Parameters:
      index - index of the element to replace
      value - element to be stored at the specified position
      Returns:
      this list
    • setIntArrayTag

      public TagList<T> setIntArrayTag(int index, TagIntArray value)
      Replaces an element at the specified position in the list
      Parameters:
      index - index of the element to replace
      value - element to be stored at the specified position
      Returns:
      this list
    • setLongArrayTag

      public TagList<T> setLongArrayTag(int index, TagLongArray value)
      Replaces an element at the specified position in the list
      Parameters:
      index - index of the element to replace
      value - element to be stored at the specified position
      Returns:
      this list
    • setStringTag

      public TagList<T> setStringTag(int index, TagString value)
      Replaces an element at the specified position in the list
      Parameters:
      index - index of the element to replace
      value - element to be stored at the specified position
      Returns:
      this list
    • setCompound

      public TagList<T> setCompound(int index, TagCompound value)
      Replaces an element at the specified position in the list
      Parameters:
      index - index of the element to replace
      value - element to be stored at the specified position
      Returns:
      this list
    • setList

      public TagList<T> setList(int index, TagList<?> value)
      Replaces an element at the specified position in the list
      Parameters:
      index - index of the element to replace
      value - element to be stored at the specified position
      Returns:
      this list
    • remove

      public TagList<T> remove(int index)
      Removes the element at the specified position in this list
      Parameters:
      index - index of the element to be removed
      Returns:
      this list
    • clear

      public TagList<T> clear()
      Removes all of the elements from this list
      Returns:
      this list
    • size

      public int size()
      Returns the number of elements in this list
      Returns:
      the number of elements in this list
    • isEmpty

      public boolean isEmpty()
      Returns true if this list contains no elements.
      Returns:
      true if this list contains no elements
    • asByteList

      public TagList<TagByte> asByteList()
      Returns this list, casted to a list of bytes
      Returns:
      this list
    • asShortList

      public TagList<TagShort> asShortList()
      Returns this list, casted to a list of shorts
      Returns:
      this list
    • asIntList

      public TagList<TagInt> asIntList()
      Returns this list, casted to a list of ints
      Returns:
      this list
    • asLongList

      public TagList<TagLong> asLongList()
      Returns this list, casted to a list of longs
      Returns:
      this list
    • asFloatList

      public TagList<TagFloat> asFloatList()
      Returns this list, casted to a list of floats
      Returns:
      this list
    • asDoubleList

      public TagList<TagDouble> asDoubleList()
      Returns this list, casted to a list of doubles
      Returns:
      this list
    • asByteArrayList

      public TagList<TagByteArray> asByteArrayList()
      Returns this list, casted to a list of byte arrays
      Returns:
      this list
    • asIntArrayList

      public TagList<TagIntArray> asIntArrayList()
      Returns this list, casted to a list of int arrays
      Returns:
      this list
    • asLongArrayList

      public TagList<TagLongArray> asLongArrayList()
      Returns this list, casted to a list of long arrays
      Returns:
      this list
    • asStringList

      public TagList<TagString> asStringList()
      Returns this list, casted to a list of strings
      Returns:
      this list
    • asCompoundList

      public TagList<TagCompound> asCompoundList()
      Returns this list, casted to a list of compounds
      Returns:
      this list
    • asListList

      public TagList<TagList<?>> asListList()
      Returns this list, casted to a list of lists
      Returns:
      this list
    • asListList

      public <X extends Tag<?>> TagList<TagList<X>> asListList(Class<X> componentType)
      Returns this list, casted to a list of lists, where each list should only contain elements of type componentType
      Type Parameters:
      X - type of the elements of the lists
      Parameters:
      componentType - class of the type of the elements of the lists
      Returns:
      this list
    • iterator

      public Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T extends Tag<?>>
    • getComponentType

      public TagType getComponentType()
      Returns the type of elements in this list. May be null if the list was created via emptyList()
      Returns:
      the type of elements in this list