IEnchantmentDefinition
Link to ienchantmentdefinition
An IEnchantmentDefinition is the actual Enchantment, it does not posess a level, but you can use this to retrieve information on the Enchantment.
패키지 임포트하기
Link to 패키지-임포트하기
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.
import crafttweaker.enchantments.IEnchantmentDefinition;
Retrieving such an object
Link to retrieving-such-an-object
You can retrieve such an object from the Enchantment Bracket handler or from an IEnchantment object.
ZenGetters/ZenSetters
Link to zengetterszensetters
ZenGetter | ZenSetter | Type |
---|---|---|
ZenGetter id | ZenSetter | Type int |
ZenGetter name | ZenSetter name | Type string |
ZenGetter maxLevel | ZenSetter | Type int |
ZenGetter minLevel | ZenSetter | Type int |
ZenGetter isAllowedOnBooks | ZenSetter | Type boolean |
ZenGetter isTreasureEnchantment | ZenSetter | Type boolean |
ZenGetter isCurse | ZenSetter | Type boolean |
ZenGetter registryName | ZenSetter | Type string |
ZenMethods
Link to zenmethods
CanApply
Link to canapply
Checks if the enchantment can be put on the item.
First method checks in general, second checks if the item can be enchanted to this enchantment using the enchantment Table.
Both return a bool and require an IItemStack as input parameter.
ZenScript Copyench.canApply(IItemStack item);
ench.canApplyAtEnchantmentTable(IItemStack item);
getEnchantability
Link to getenchantability
Checks what enchantability the item must have for the Enchantment at the given level.
Both methods return an int and take the level of the enchantment as int parameter.
ZenScript Copyench.getMinEnchantability(int level);
ench.getMaxEnchantability(int level);
TranslatedName
Link to translatedname
Returns the translated name (e.g. "smite IV").
Returns a string and requires the level of the enchantment as int parameter.
Does the same as IEnchantment's .displayName
ZenGetter!
objectzenscriptivec Copyench.getTranslatedName(int level);
make Enchantment
Link to make-enchantment
By giving an EnchantmentDefinition a level you can make an IEnchantment out of it:
ZenScript Copyench.makeEnchantment(int level);
ench * level;
Compare with other IEnchantmentDefinition objects
Link to compare-with-other-ienchantmentdefinition-objects
You can use the ==
operator to check if two enchantments are the same.
This means if they have the same id.
ZenScript Copyif(enchA == enchB)
print("Same!");
ZenScript Copyimport crafttweaker.enchantments.IEnchantmentDefinition;
import crafttweaker.data.IData;
val array as IEnchantmentDefinition[] = [<enchantment:minecraft:protection>,<enchantment:minecraft:fire_protection>,<enchantment:minecraft:feather_falling>,<enchantment:minecraft:blast_protection>,<enchantment:minecraft:projectile_protection>,<enchantment:minecraft:respiration>,<enchantment:minecraft:aqua_affinity>];
var map as IData = {};
for ench in array {
map += ench.makeEnchantment(3).makeTag();
}
print(map.asString());
recipes.addShapeless("Supo", <minecraft:golden_sword>.withTag(map), [<minecraft:iron_sword>, <minecraft:golden_sword>]);