KnownTag<T : Object>

A known tag is a tag whose element is known and has been registered as Taggable.

Known tags let you use the actual element to interact with the tag instead of using the registry key of the element

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.type.KnownTag;

Implemented Interfaces

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

  • MCTag
  • stdlib.Iterable<T>

Casters

Result TypeIs Implicit
Result Type
Many<KnownTag<T>>
Is Implicit
true
Result Type
string
Is Implicit
true

Methods

script.zs
KnownTag.add(elements as T[])
ParameterType
Parameter
elements
Type
T[]

Adds the given tags to this tag.

script.zs
// KnownTag.add(tags as MCTag[])
myKnownTag.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
// KnownTag.addId(elements as ResourceLocation[])
myKnownTag.addId(<resource:minecraft:diamond>);
ParameterTypeDescription
Parameter
elements
Type
ResourceLocation[]
Description
The registry key of the elements to add.

Return Type: Many<KnownTag<T>>

script.zs
// KnownTag.asTagWithAmount() as Many<KnownTag<T>>
myKnownTag.asTagWithAmount();

Removes all elements in this tag.

script.zs
// KnownTag.clear()
myKnownTag.clear();

Return Type: boolean

script.zs
KnownTag.contains(element as T) as boolean
ParameterType
Parameter
element
Type
T

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
// KnownTag.contains(id as ResourceLocation) as boolean
myKnownTag.contains(<resource:minecraft:white_wool>);
ParameterTypeDescription
Parameter
id
Type
ResourceLocation
Description
The ID of the element to check.

Return Type: stdlib.List<T>

script.zs
// KnownTag.elements() as stdlib.List<T>
myKnownTag.elements();

Checks if this tag equals the other tag.

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

script.zs
// KnownTag.equals(other as MCTag) as boolean
myKnownTag.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
// KnownTag.exists() as boolean
myKnownTag.exists();

Return Type: ResourceLocation

script.zs
// KnownTag.id() as ResourceLocation
myKnownTag.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
// KnownTag.idElements() as stdlib.List<ResourceLocation>
myKnownTag.idElements();

Return Type: KnownTagManager<T>

script.zs
// KnownTag.manager() as KnownTagManager<T>
myKnownTag.manager();
script.zs
KnownTag.remove(elements as T[])
ParameterType
Parameter
elements
Type
T[]

Removes the given tags from this tag.

script.zs
// KnownTag.remove(tags as MCTag[])
myKnownTag.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
// KnownTag.removeId(elements as ResourceLocation[])
myKnownTag.removeId(<resource:minecraft:diamond>);
ParameterTypeDescription
Parameter
elements
Type
ResourceLocation[]
Description
The registry key of the elements to remove.

Return Type: Many<KnownTag<T>>

script.zs
KnownTag.withAmount(amount as int) as Many<KnownTag<T>>
ParameterType
Parameter
amount
Type
int

Operators

Checks if this tag contains an element with the given id

script.zs
id as ResourceLocation in myKnownTag
<resource:minecraft:white_wool> in myKnownTag

Checks if this tag equals the other tag.

script.zs
myKnownTag == other as MCTag
myKnownTag == <tag:items:minecraft:wool>
script.zs
myKnownTag * amount as int

Properties

NameTypeHas GetterHas SetterDescription
Name
elements
Type
stdlib.List<T>
Has Getter
true
Has Setter
false
Description
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
Name
idElements
Type
stdlib.List<ResourceLocation>
Has Getter
true
Has Setter
false
Description
Gets the id’s of the elements in this tag.
Name
manager
Type
KnownTagManager<T>
Has Getter
true
Has Setter
false
Description