|
本帖最后由 QQ酱199171 于 2023-11-9 17:01 编辑
这是适用于新版本的示例代码,原理和之前那个帖子是一样的,需要教程的再和我说
- import crafttweaker.api.item.IItemStack;
- import crafttweaker.api.ingredient.IIngredient;
- import crafttweaker.api.entity.attribute.AttributeOperation;
- //将铁头盔的护甲值修改为15
- var armor_value = 15.0;
- <item:minecraft:iron_helmet>.anyDamage().addGlobalAttributeModifier(
- <attribute:minecraft:generic.armor>, // 修饰的属性为护甲值
- "2ad3f246-fee1-4e67-b886-69fd380bb150", // 原版槽位为头部,属性为护甲值的物品的属性修饰符的uuid,可用指令获取
- "Armor modifier", // 添加的修饰符的名称
- armor_value, // 添加的修饰符的具体修饰值
- AttributeOperation.ADDITION, // 确定修饰符运算模式为加法
- [<constant:minecraft:equipmentslot:head>] // 设定修饰符起作用的物品栏槽位只有头部
- );
- //将铁头盔的盔甲韧性修改为5
- var toughness = 5.0;
- <item:minecraft:iron_helmet>.anyDamage().addGlobalAttributeModifier(
- <attribute:minecraft:generic.armor_toughness>, // 修饰的属性为盔甲韧性
- "2ad3f246-fee1-4e67-b886-69fd380bb150", // 原版槽位为头部,属性为盔甲韧性的物品的属性修饰符的uuid,巧合地与护甲值修饰符一致
- "Armor toughness", // 添加的修饰符的名称
- toughness, // 添加的修饰符的具体修饰值
- AttributeOperation.ADDITION, // 确定修饰符运算模式为加法
- [<constant:minecraft:equipmentslot:head>] // 设定修饰符起作用的物品栏槽位只有头部
- );
- //将铁剑在主手的伤害修改为20
- var damage = 19.0;
- <item:minecraft:iron_sword>.anyDamage().addGlobalAttributeModifier(
- <attribute:minecraft:generic.attack_damage>, // 修饰的属性为攻击伤害
- IItemStack.BASE_ATTACK_DAMAGE_UUID, // 原版槽位为主手,属性为攻击伤害的物品的属性修饰符的uuid,推荐直接调用CraftTweaker设置的常量
- "Weapon modifier", // 添加的修饰符的名称
- damage, // 添加的修饰符的具体修饰值
- AttributeOperation.ADDITION, // 确定修饰符运算模式为加法
- [<constant:minecraft:equipmentslot:mainhand>] // 设定修饰符起作用的物品栏槽位只有主手
- );
- //将铁剑在主手的攻速修改为3,玩家初始攻速为4,因此设置的数值为(3-4)=-1
- var attackspeed = -1.0;
- <item:minecraft:iron_sword>.anyDamage().addGlobalAttributeModifier(
- <attribute:minecraft:generic.attack_speed>, // 修饰的属性为攻速
- IItemStack.BASE_ATTACK_SPEED_UUID, // 原版槽位为主手,属性为攻速的物品的属性修饰符的uuid,推荐直接调用CraftTweaker设置的常量
- "Weapon modifier", // 添加的修饰符的名称
- attackspeed, // 添加的修饰符的具体修饰值
- AttributeOperation.ADDITION, // 确定修饰符运算模式为加法
- [<constant:minecraft:equipmentslot:mainhand>] // 设定修饰符起作用的物品栏槽位只有主手
- );
- //将铁剑耐久值修改为3200
- <item:minecraft:iron_sword>.maxDamage = 3200;
复制代码 |
|