Home Commands Examples Getting Started With Scripts Global Keywords

ITagManager<T : MCTag>

Importing the class

It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.

script.zs
import crafttweaker.api.tag.manager.ITagManager;

Implemented Interfaces

ITagManager implements the following interfaces. That means all methods defined in these interfaces are also available in ITagManager

Methods

Adds the elements that correspond to the given ResourceLocation to the given tag.

script.zs
// ITagManager.addId(to as T, values as ResourceLocation[])
<tagmanager:items>.addId(<tag:items:minecraft:wool>, <resource:minecraft:diamond>);
ParameterTypeDescription
Parameter
to
Type
T
Description
The tag to add to.
Parameter
values
Type
ResourceLocation[]
Description
The registry key of the elements to add.

Clears all values of the given tag.

script.zs
// ITagManager.clear(from as T)
<tagmanager:items>.clear(<tag:items:minecraft:wool>);
ParameterTypeDescription
Parameter
from
Type
T
Description
The tag to clear.

Checks if a tag with the given id exists and is registered.

Returns: true if it exists, false otherwise.
Return Type: boolean

script.zs
// ITagManager.exists(id as ResourceLocation) as boolean
<tagmanager:items>.exists(<resource:minecraft:wool>);
ParameterTypeDescription
Parameter
id
Type
ResourceLocation
Description
The id of the tag to check.

Checks if a tag with the given id exists and is registered.

Returns: true if it exists, false otherwise.
Return Type: boolean

script.zs
// ITagManager.exists(id as string) as boolean
<tagmanager:items>.exists("minecraft:wool");
ParameterTypeDescription
Parameter
id
Type
string
Description
The id of the tag to check.

Checks if the given tag exists and is registered.

Returns: true if it exists, false otherwise.
Return Type: boolean

script.zs
// ITagManager.exists(tag as T) as boolean
<tagmanager:items>.exists(<tag:items:minecraft:wool>);
ParameterTypeDescription
Parameter
tag
Type
T
Description
The tag to check.

Ges the tags that contain the given element.

Returns: The tags that contain the given elements.
Return Type: stdlib.List<T>

script.zs
ITagManager.getTagsFor(element as ResourceLocation) as stdlib.List<T>
ParameterType
Parameter
element
Type
ResourceLocation

Gets the ResourceLocation ids of the elements in the given tag.

Returns: A List of ResourceLocation ids of the elements in the given tag.
Return Type: stdlib.List<ResourceLocation>

script.zs
// ITagManager.idElements(of as T) as stdlib.List<ResourceLocation>
<tagmanager:items>.idElements(<tag:items:minecraft:wool>);
ParameterTypeDescription
Parameter
of
Type
T
Description
The tag to get the elements of.

Removes the elements that correspond to the given ResourceLocation from the given tag.

script.zs
// ITagManager.removeId(from as T, values as ResourceLocation[])
<tagmanager:items>.removeId(<tag:items:minecraft:wool>, <resource:minecraft:diamond>);
ParameterTypeDescription
Parameter
from
Type
T
Description
The tag to remove from.
Parameter
values
Type
ResourceLocation[]
Description
The registry key of the elements to remove.

Gets a tag with the given id.

Returns: A tag with the given id.
Return Type: T

script.zs
// ITagManager.tag(id as ResourceLocation) as T
<tagmanager:items>.tag(<resource:minecraft:wool>);
ParameterTypeDescription
Parameter
id
Type
ResourceLocation
Description
The id of the tag.

Gets a tag with the given id.

Returns: A tag with the given id.
Return Type: T

script.zs
// ITagManager.tag(id as string) as T
<tagmanager:items>.tag("minecraft:wool");
ParameterTypeDescription
Parameter
id
Type
string
Description
The id of the tag.

Gets the tagFolder of this manager.

The tag folder is usually the folder on disk without the tags/ prefix.

Examples:

  • `tags/items` turns into `items`
  • `tags/potion` turns into `potion`
  • `tags/worldgen/biome` turns into `worldgen/biome`

Returns: The tag folder of this manager.
Return Type: string

script.zs
// ITagManager.tagFolder() as string
<tagmanager:items>.tagFolder();

Gets the keys of the tags that this manager knows about.

Returns: A List of keys of the tags that this manager knows about.
Return Type: stdlib.List<ResourceLocation>

script.zs
// ITagManager.tagKeys() as stdlib.List<ResourceLocation>
<tagmanager:items>.tagKeys();

Gets a map of id to tag that this manager knows about.

Returns: a map of id to tag.
Return Type: T[ResourceLocation]

script.zs
// ITagManager.tagMap() as T[ResourceLocation]
<tagmanager:items>.tagMap();

Ges the tags that this manager knows about.

Returns: The tags that this manager knows about.
Return Type: stdlib.List<T>

script.zs
// ITagManager.tags() as stdlib.List<T>
<tagmanager:items>.tags();

Operators

Checks if a tag with the given id exists and is registered.

script.zs
id as string in myITagManager
"minecraft:wool" in <tagmanager:items>

Properties

NameTypeHas GetterHas SetterDescription
Name
tagFolder
Type
string
Has Getter
true
Has Setter
false
Description
Gets the tagFolder of this manager.

The tag folder is usually the folder on disk without the tags/ prefix.

Examples:

  • tags/items turns into items

  • tags/potion turns into potion

  • tags/worldgen/biome turns into worldgen/biome

Name
tagKeys
Type
stdlib.List<ResourceLocation>
Has Getter
true
Has Setter
false
Description
Gets the keys of the tags that this manager knows about.
Name
tagMap
Type
T[ResourceLocation]
Has Getter
true
Has Setter
false
Description
Gets a map of id to tag that this manager knows about.
Name
tags
Type
stdlib.List<T>
Has Getter
true
Has Setter
false
Description
Ges the tags that this manager knows about.