Class Collection_Tag
- Direct Known Subclasses:
Tag_Compound,Tag_List
Provides comprehensive functionality for managing child tags including addition, removal, and retrieval operations. Supports both name-based and object-based lookups with optional recursive searching.
Implements fluent API patterns for method chaining and offers specialized handling for different collection types (compounds vs. lists).
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionCollection_Tag(int id) Creates a collection tag with the specified NBT type identifier.Collection_Tag(int id, String name) Creates a named collection tag with the specified NBT type identifier.Collection_Tag(int id, String name, ArrayList<Tag<?>> data) Creates a collection tag pre-populated with child tags. -
Method Summary
Modifier and TypeMethodDescriptionaddAllTags(List<Tag<?>> tags) Adds multiple child tags to this collection with batch type validation.Adds a child tag to this collection with type validation.getAllTags(Tag<?> targetTag) Finds all tags that are equal to the specified target tag.getAllTagsByName(String name) Finds all tags with the specified name, including nested matches.Tag<?> Finds the first tag that equals the specified target tag.Tag<?> getTagByName(String name) Finds the first tag with the specified name, including nested search.voidremoveAllTags(Tag<?> targetTag) Removes all tags equal to the specified target from this collection and descendants.voidremoveAllTagsByName(String name) Removes all tags with the specified name from this collection and descendants.Removes the first tag equal to the specified target and returns this collection.removeTagByName(String name) Removes the first tag with the specified name and returns this collection.
-
Constructor Details
-
Collection_Tag
public Collection_Tag(int id) Creates a collection tag with the specified NBT type identifier. Initializes with an empty ArrayList for child tags.- Parameters:
id- the NBT type identifier
-
Collection_Tag
Creates a named collection tag with the specified NBT type identifier. Initializes with an empty ArrayList for child tags.- Parameters:
id- the NBT type identifiername- the tag name
-
Collection_Tag
-
-
Method Details
-
addTag
Adds a child tag to this collection with type validation.For lists, validates that the new tag matches the declared list type. Compounds accept any tag type.
- Parameters:
tag- the tag to add- Returns:
- this collection tag for method chaining
- Throws:
IllegalArgumentException- if adding incompatible type to a list- See Also:
-
addAllTags
Adds multiple child tags to this collection with batch type validation.For lists, validates that all new tags match the declared list type before adding any elements.
- Parameters:
tags- the collection of tags to add- Returns:
- this collection tag for method chaining
- Throws:
IllegalArgumentException- if any tag is incompatible with list type- See Also:
-
getAllTagsByName
-
getTagByName
-
getAllTags
Finds all tags that are equal to the specified target tag.Uses
Tag.equals(Object)for comparison and searches recursively.- Parameters:
targetTag- the tag to match against- Returns:
- list of equal tags (empty if none found)
- See Also:
-
getTag
-
removeAllTagsByName
Removes all tags with the specified name from this collection and descendants.Performs recursive removal through all nested collections.
- Parameters:
name- the tag name to remove- See Also:
-
removeTagByName
Removes the first tag with the specified name and returns this collection.Stops after removing the first match found during traversal.
- Parameters:
name- the tag name to remove- Returns:
- this collection tag for method chaining
- See Also:
-
removeAllTags
Removes all tags equal to the specified target from this collection and descendants.Uses
Tag.equals(Object)for comparison and removes recursively.- Parameters:
targetTag- the tag to remove- See Also:
-
removeTag
Removes the first tag equal to the specified target and returns this collection.Stops after removing the first match found during traversal.
- Parameters:
targetTag- the tag to remove- Returns:
- this collection tag for method chaining
- See Also:
-