Home Migration Guide Getting Started With Scripts Commands Examples
BracketHandlers

MCTag<T : Object>

A reference to a Tag object. Note that this tag may not exist in the game already, such as when you create new tags. See the MCTag<T>#exists() Method on whether or not this tag already exists.

A tag will be created as soon as you add

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.MCTag;

Implemented Interfaces

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

Casters

Result typeIs Implicit
Result type
MCTagWithAmount<T>
Is Implicit
true
Result type
string
Is Implicit
true

Methods

Adds the given items to the tag. Creates the tag if it does not exist.

Return Type: void

script.zs
MCTag.add(items as stdlib.List<T>) as void
ParameterTypeDescription
Parameter
items
Type
stdlib.List<T>
Description
The items to add. Provided as list.

Adds the given items to the tag. Creates the tag if it does not exist.

Return Type: void

script.zs
// MCTag.add(items as T[]) as void
<tag:items:forge:gems>.add(<item:minecraft:bedrock>);
<tag:items:forge:gems>.add(<item:minecraft:iron_ingot>, <item:minecraft:gold_ingot>);
<tag:items:forge:gems>.add([<item:minecraft:iron_ingot>, <item:minecraft:gold_ingot>]);
ParameterTypeDescription
Parameter
items
Type
T[]
Description
The items to add. Can be one or more items.

Adds the given tag to this tag. Creates the tag if it does not exist.

Return Type: void

script.zs
// MCTag.add(tag as MCTag<T>) as void
<tag:items:forge:gems>.add(<tag:items:forge:rods>);
ParameterTypeDescription
Parameter
tag
Type
MCTag<T>
Description
The tag to add.

Adds the given tags to this tag. Creates the tag if it does not exist.

Return Type: void

script.zs
// MCTag.addTags(tags as stdlib.List<MCTag<T>>) as void
<tag:items:forge:gems>.addTags(<tag:items:forge:rods>);
ParameterTypeDescription
Parameter
tags
Type
stdlib.List<MCTag<T>>
Description
The tags to add.

Return Type: MCTagWithAmount<T>

script.zs
// MCTag.asTagWithAmount() as MCTagWithAmount<T>
<tag:items:forge:gems>.asTagWithAmount();

Return Type: boolean

script.zs
MCTag.contains(element as T) as boolean
ParameterTypeDescription
Parameter
element
Type
T
Description
No Description Provided

Return Type: boolean

script.zs
// MCTag.exists() as boolean
<tag:items:forge:gems>.exists();

Return Type: stdlib.List<T>

script.zs
// MCTag.getElements() as stdlib.List<T>
<tag:items:forge:gems>.getElements();

Return Type: MCResourceLocation

script.zs
// MCTag.getId() as MCResourceLocation
<tag:items:forge:gems>.getId();

Return Type: TagManager<T>

script.zs
// MCTag.getManager() as TagManager<T>
<tag:items:forge:gems>.getManager();

Return Type: void

script.zs
MCTag.remove(items as stdlib.List<T>) as void
ParameterTypeDescription
Parameter
items
Type
stdlib.List<T>
Description
No Description Provided

Return Type: void

script.zs
MCTag.remove(items as T[]) as void
ParameterTypeDescription
Parameter
items
Type
T[]
Description
No Description Provided

Return Type: void

script.zs
MCTag.remove(tag as MCTag<T>) as void
ParameterTypeDescription
Parameter
tag
Type
MCTag<T>
Description
No Description Provided

Return Type: MCTagWithAmount<T>

script.zs
MCTag.withAmount(amount as int) as MCTagWithAmount<T>
ParameterTypeDescription
Parameter
amount
Type
int
Description
No Description Provided

Operators

script.zs
element as T in myMCTag
script.zs
myMCTag == other as MCTag<T>
script.zs
myMCTag * amount as int

Properties

NameTypeHas GetterHas SetterDescription
Name
elements
Type
stdlib.List<T>
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
exists
Type
boolean
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
id
Type
MCResourceLocation
Has Getter
true
Has Setter
false
Description
No Description Provided
Name
manager
Type
TagManager<T>
Has Getter
true
Has Setter
false
Description
No Description Provided