Skip to content

Class ListTag

Namespace: Void.Minecraft.Nbt
Assembly: Void.Minecraft.dll

Represents a collection of a tags.

public class ListTag : Tag, IEquatable<Tag>, ICloneable, IList<Tag>, ICollection<Tag>, IEnumerable<Tag>, IEnumerable

Inheritance

objectTagListTag

Implements

IEquatable<Tag>, ICloneable, IList<Tag>, ICollection<Tag>, IEnumerable<Tag>, IEnumerable

Inherited Members

Tag.NoName, Tag.Type, Tag.Parent, Tag.Name, Tag.PrettyPrinted(StringBuilder, int, string), Tag.PrettyName, Tag.WriteJson(Utf8JsonWriter, bool), Tag.WriteJson(Stream, JsonWriterOptions?), Tag.WriteJsonAsync(Stream, JsonWriterOptions?), Tag.ToJson(JsonWriterOptions?), Tag.ToJsonString(bool, string), Tag.Equals(Tag?), Tag.Equals(object?), Tag.GetHashCode(), Tag.Clone(), Tag.Stringify(bool), Tag.StringifyName, object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

Extension Methods

EnumerableExtensions.Synchronized<Tag>(IEnumerable<Tag>, AsyncLock, CancellationToken), EnumerableExtensions.SynchronizedAsync<Tag>(IEnumerable<Tag>, AsyncLock, CancellationToken)

Remarks

All child tags must be have the same value, and their value will be omitted during serialization.

Constructors

ListTag(string?, TagType)

Creates a new instance of the class.

public ListTag(string? name, TagType childType)

Parameters

name string?

The name of the tag, or null if tag has no name.

childType TagType

A constant describing the NBT type for children in this tag.

ListTag(string?, TagType, int)

Creates a new instance of the class.

public ListTag(string? name, TagType childType, int capacity)

Parameters

name string?

The name of the tag, or null if tag has no name.

childType TagType

A constant describing the NBT type for children in this tag.

capacity int

The initial capacity of the list.

ListTag(string?, TagType, IEnumerable<Tag>)

Creates a new instance of the with the specified children.

public ListTag(string? name, TagType childType, IEnumerable<Tag> children)

Parameters

name string?

The name of the tag, or null if tag has no name.

childType TagType

A constant describing the NBT type for children in this tag.

children IEnumerable<Tag>

A collection of values to include in this tag.

Properties

ChildType

Gets the NBT type of this tag’s children.

public TagType ChildType { get; }

Property Value

TagType

Count

Gets the number of elements contained in the .

public int Count { get; }

Property Value

int

this[int]

Gets or sets the element at the specified index.

public Tag this[int index] { get; set; }

Property Value

Tag

Exceptions

ArgumentOutOfRangeException

index is not a valid index in the .

NotSupportedException

The property is set and the is read-only.

Methods

Add(Tag)

Adds an item to the .

public void Add(Tag item)

Parameters

item Tag

The object to add to the .

Exceptions

NotSupportedException

The is read-only.

AddRange(IEnumerable<Tag>)

public void AddRange(IEnumerable<Tag> items)

Parameters

items IEnumerable<Tag>

Clear()

Removes all items from the .

public void Clear()

Exceptions

NotSupportedException

The is read-only.

Contains(Tag)

Determines whether the contains a specific value.

public bool Contains(Tag item)

Parameters

item Tag

The object to locate in the .

Returns

bool

true if item is found in the ; otherwise, false.

CopyTo(Tag[], int)

Copies the elements of the to an , starting at a particular index.

public void CopyTo(Tag[] array, int arrayIndex)

Parameters

array Tag[]

The one-dimensional that is the destination of the elements copied from . The must have zero-based indexing.

arrayIndex int

The zero-based index in array at which copying begins.

Exceptions

ArgumentNullException

array is null.

ArgumentOutOfRangeException

arrayIndex is less than 0.

ArgumentException

The number of elements in the source is greater than the available space from arrayIndex to the end of the destination array.

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<Tag> GetEnumerator()

Returns

IEnumerator<Tag>

An enumerator that can be used to iterate through the collection.

IndexOf(Tag)

Determines the index of a specific item in the .

public int IndexOf(Tag item)

Parameters

item Tag

The object to locate in the .

Returns

int

The index of item if found in the list; otherwise, -1.

Insert(int, Tag)

Inserts an item to the at the specified index.

public void Insert(int index, Tag item)

Parameters

index int

The zero-based index at which item should be inserted.

item Tag

The object to insert into the .

Exceptions

ArgumentOutOfRangeException

index is not a valid index in the .

NotSupportedException

The is read-only.

PrettyPrinted(StringBuilder, int, string)

Writes this tag as a formatted string to the given buffer.

protected override void PrettyPrinted(StringBuilder buffer, int level, string indent)

Parameters

buffer StringBuilder

A instance to write to.

level int

The current indent depth to write at.

indent string

The string to use for indents.

PrettyPrinted(string)

Retrieves a “pretty-printed” multiline string representing the complete tree structure of the tag.

public string PrettyPrinted(string indent = " ")

Parameters

indent string

The prefix that will be applied to each indent-level of nested nodes in the tree structure.

Returns

string

The pretty-printed string.

Remove(Tag)

Removes the first occurrence of a specific object from the .

public bool Remove(Tag item)

Parameters

item Tag

The object to remove from the .

Returns

bool

true if item was successfully removed from the ; otherwise, false. This method also returns false if item is not found in the original .

Exceptions

NotSupportedException

The is read-only.

RemoveAt(int)

Removes the item at the specified index.

public void RemoveAt(int index)

Parameters

index int

The zero-based index of the item to remove.

Exceptions

ArgumentOutOfRangeException

index is not a valid index in the .

NotSupportedException

The is read-only.

Stringify(bool)

Gets the string representation of this NBT tag (SNBT).

public override string Stringify(bool named = true)

Parameters

named bool

Returns

string

This NBT tag in SNBT format.

See Also

https://minecraft.fandom.com/wiki/NBT_format#SNBT_format

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

WriteJson(Utf8JsonWriter, bool)

Uses the provided writer to write the NBT tag in JSON format.

protected override void WriteJson(Utf8JsonWriter writer, bool named = true)

Parameters

writer Utf8JsonWriter

A JSON writer instance.

named bool

Flag indicating if this object’s name should be written as a property name, or false when it is a child of , in which case it should be written as a JSON array element.