Home Commands Examples Getting Started With Scripts Global Keywords

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

Implemented Interfaces

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

Methods

Adds the given tags to this tag.

script.zs
// MCTag.add(tags as MCTag[])
<tag:items:minecraft:wool>.add(<tag:items:minecraft:wool>);
ParameterTypeDescription
Parameter
tags
Type
MCTag[]
Description
The tags to add.

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

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

Removes all elements in this tag.

script.zs
// MCTag.clear()
<tag:items:minecraft:wool>.clear();

Checks if this tag contains an element with the given id

Returns: true if it contains the element, false otherwise.
Return Type: boolean

script.zs
// MCTag.contains(id as ResourceLocation) as boolean
<tag:items:minecraft:wool>.contains(<resource:minecraft:white_wool>);
ParameterTypeDescription
Parameter
id
Type
ResourceLocation
Description
The ID of the element to check.

Checks if this tag equals the other tag.

Returns: true if the tags are equal, false otherwise.
Return Type: boolean

script.zs
// MCTag.equals(other as MCTag) as boolean
<tag:items:minecraft:wool>.equals(<tag:items:minecraft:wool>);
ParameterTypeDescription
Parameter
other
Type
MCTag
Description
The tag to check against.

Checks if this tag exists.

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

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

Gets the id of this tag.

Returns: The id of this tag.
Return Type: ResourceLocation

script.zs
// MCTag.id() as ResourceLocation
<tag:items:minecraft:wool>.id();

Gets the id’s of the elements in this tag.

Returns: The id’s elements in this tag.
Return Type: stdlib.List<ResourceLocation>

script.zs
// MCTag.idElements() as stdlib.List<ResourceLocation>
<tag:items:minecraft:wool>.idElements();

Removes the given tags from this tag.

script.zs
// MCTag.remove(tags as MCTag[])
<tag:items:minecraft:wool>.remove(<tag:items:minecraft:wool>);
ParameterTypeDescription
Parameter
tags
Type
MCTag[]
Description
The tags to remove.

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

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

Operators

Checks if this tag contains an element with the given id

script.zs
id as ResourceLocation in myMCTag
<resource:minecraft:white_wool> in <tag:items:minecraft:wool>

Checks if this tag equals the other tag.

script.zs
myMCTag == other as MCTag
<tag:items:minecraft:wool> == <tag:items:minecraft:wool>

Properties

NameTypeHas GetterHas SetterDescription
Name
exists
Type
boolean
Has Getter
true
Has Setter
false
Description
Checks if this tag exists.
Name
id
Type
ResourceLocation
Has Getter
true
Has Setter
false
Description
Gets the id of this tag.
Name
idElements
Type
stdlib.List<ResourceLocation>
Has Getter
true
Has Setter
false
Description
Gets the id’s of the elements in this tag.