Importing the class

Link to 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.

ZenScript
Copy
import crafttweaker.api.item.enchantment.Enchantment;

Extending Record

Link to extending-record

Enchantment extends Record. That means all methods available in Record are also available in Enchantment

Name: canEnchant

Return Type: boolean

ZenScript
Copy
Enchantment.canEnchant(stack as IItemStack) as boolean
ParameterType
Parameter
stack
Type
IItemStack

Name: getMaxCost

Return Type: int

ZenScript
Copy
Enchantment.getMaxCost(level as int) as int
ParameterType
Parameter
level
Type
int

Name: getMinCost

Return Type: int

ZenScript
Copy
Enchantment.getMinCost(level as int) as int
ParameterType
Parameter
level
Type
int

Name: getSlotItems

Return Type: IItemStack[EquipmentSlot]

ZenScript
Copy
Enchantment.getSlotItems(entity as LivingEntity) as IItemStack[EquipmentSlot]
ParameterType
Parameter
entity
Type
LivingEntity

Name: isPrimaryItem

Return Type: boolean

ZenScript
Copy
Enchantment.isPrimaryItem(stack as IItemStack) as boolean
ParameterType
Parameter
stack
Type
IItemStack

Name: isSupportedItem

Return Type: boolean

ZenScript
Copy
Enchantment.isSupportedItem(stack as IItemStack) as boolean
ParameterType
Parameter
stack
Type
IItemStack

Name: matchingSlot

Return Type: boolean

ZenScript
Copy
Enchantment.matchingSlot(slot as EquipmentSlot) as boolean
ParameterType
Parameter
slot
Type
EquipmentSlot
NameTypeHas GetterHas Setter
Name
Type
int
Has Getter
true
Has Setter
false
Name
anvilCost
Type
int
Has Getter
true
Has Setter
false
Name
commandString
Type
string
Has Getter
true
Has Setter
false
Name
definition
Type
EnchantmentDefinition
Has Getter
true
Has Setter
false
Name
description
Type
Component
Has Getter
true
Has Setter
false
Name
exclusiveSet
Type
Enchantment[]
Has Getter
true
Has Setter
false
Name
minLevel
Type
int
Has Getter
true
Has Setter
false
Name
registryName
Type
ResourceLocation
Has Getter
true
Has Setter
false
Name
supportedItems
Type
ItemDefinition[]
Has Getter
true
Has Setter
false
Name
weight
Type
int
Has Getter
true
Has Setter
false