Home Migration Guide Getting Started With Scripts Commands Examples
BracketHandlers

EnchantmentType

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.enchantment.EnchantmentType;

Enum Constants

EnchantmentType is an enum. It has 14 enum constants. They are accessible using the code below.

script.zs
EnchantmentType.ARMOR
EnchantmentType.ARMOR_FEET
EnchantmentType.ARMOR_LEGS
EnchantmentType.ARMOR_CHEST
EnchantmentType.ARMOR_HEAD
EnchantmentType.WEAPON
EnchantmentType.DIGGER
EnchantmentType.FISHING_ROD
EnchantmentType.TRIDENT
EnchantmentType.BREAKABLE
EnchantmentType.BOW
EnchantmentType.WEARABLE
EnchantmentType.CROSSBOW
EnchantmentType.VANISHABLE

Static Methods

Creates a new EnchantmentType with the given name and given can enchantment predicate.

Returns: A new EnchantmentType with the given name and predicate.
Return Type: EnchantmentType

script.zs
EnchantmentType.create(name as string, canEnchantPredicate as Predicate<MCItemDefinition>) as EnchantmentType
ParameterTypeDescription
Parameter
name
Type
string
Description
The name of the new EnchantmentType.
Parameter
canEnchantPredicate
Type
Predicate<MCItemDefinition>
Description
The can enchant predicate.

Creates a new List of EnchantmentType that are applicable to an item.

Returns: A new List of EnchantmentType that are applicable to an item.
Return Type: stdlib.List<EnchantmentType>

script.zs
// EnchantmentType.getTypesForItem(item as MCItemDefinition) as stdlib.List<EnchantmentType>
EnchantmentType.getTypesForItem(<item:minecraft:diamond_sword>);
ParameterTypeDescription
Parameter
item
Type
MCItemDefinition
Description
The item to calculate applicable enchantment types for.

Methods

Checks if the given Item can be enchanted with this EnchantmentType

Returns: True if the Item can be enchanted. False otherwise.
Return Type: boolean

script.zs
EnchantmentType.canEnchantItem(itemIn as MCItemDefinition) as boolean
ParameterTypeDescription
Parameter
itemIn
Type
MCItemDefinition
Description
No Description Provided

Creates a new List of MCEnchantment that define the EnchantmentType as their type.

Returns: A new List of MCEnchantment that define the EnchantmentType as their type.
Return Type: stdlib.List<MCEnchantment>

script.zs
// EnchantmentType.getEnchantments() as stdlib.List<MCEnchantment>
EnchantmentType.ARMOR.getEnchantments();

Creates a new List of ItemDefinition that are valid for this EnchantmentType.

Returns: A new List of ItemDefinition that are valid for this EnchantmentType.
Return Type: stdlib.List<MCItemDefinition>

script.zs
// EnchantmentType.getItems() as stdlib.List<MCItemDefinition>
EnchantmentType.ARMOR.getItems();