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>, IEnumerableInheritance
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
Constructors
ListTag(string?, TagType)
Creates a new instance of the
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
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 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
Count
Gets the number of elements contained in the
public int Count { get; }Property Value
this[int]
Gets or sets the element at the specified index.
public Tag this[int index] { get; set; }Property Value
Exceptions
index is not a valid index in the
The property is set and the
Methods
Add(Tag)
Adds an item to the
public void Add(Tag item)Parameters
item Tag
The object to add to the
Exceptions
The
AddRange(IEnumerable<Tag>)
public void AddRange(IEnumerable<Tag> items)Parameters
items IEnumerable<Tag>
Clear()
Removes all items from the
public void Clear()Exceptions
The
Contains(Tag)
Determines whether the
public bool Contains(Tag item)Parameters
item Tag
The object to locate in the
Returns
true if item is found in the
CopyTo(Tag[], int)
Copies the elements of the
public void CopyTo(Tag[] array, int arrayIndex)Parameters
array Tag[]
The one-dimensional
arrayIndex int
The zero-based index in array at which copying begins.
Exceptions
array is null.
arrayIndex is less than 0.
The number of elements in the source arrayIndex to the end of the destination array.
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<Tag> GetEnumerator()Returns
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
The index of item if found in the list; otherwise, -1.
Insert(int, Tag)
Inserts an item to the
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
index is not a valid index in the
The
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
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
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
true if item was successfully removed from the item is not found in the original
Exceptions
The
RemoveAt(int)
Removes the
public void RemoveAt(int index)Parameters
index int
The zero-based index of the item to remove.
Exceptions
index is not a valid index in the
The
Stringify(bool)
Gets the string representation of this NBT tag (SNBT).
public override string Stringify(bool named = true)Parameters
named bool
Returns
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
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