起因是1.21.1怎么也没找到添加套装奖励的mod,遂自己写了一个适用于kjs7的脚本
放在startup_scripts下:
const INFINITE = Java.loadClass('java.lang.Integer').MAX_VALUE;
const bonuses = {
set1: {
armors: ['minecraft:leather_helmet', 'minecraft:leather_boots'],
bonus: ['speed', 0]
},
set2: {
armors: ['minecraft:diamond_leggings'],
bonus: ['glowing', 0, true]
},
set3: {
armors: ['minecraft:diamond_chestplate'],
bonus: ['regeneration', 1, true]
}
};
function armor_set_bonus(context) {
const { entity, previousStack, currentStack } = context;
const { potionEffects, armorSlots } = entity;
const now_set = armorSlots.toArray().map(i => i.id);
const last_set = armorSlots.toArray().map(i => (i.id === currentStack.id ? previousStack.id : i.id));
Object.keys(bonuses).forEach(set => {
const data = bonuses[set];
const { armors, bonus } = data;
// 移除旧的套装奖励
if (!armors.every(a => last_set.includes(a))) {
entity.removeEffect(bonus[0]);
}
// 添加新的套装奖励
if (armors.every(a => now_set.includes(a))) {
potionEffects.add(bonus[0], INFINITE, bonus[1] || 0, true, bonus[2] || false);
}
});
}
EntityJSEvents.modifyEntity(e => e.modify(
'minecraft:player', modifyBuilder => modifyBuilder.onEquipItem(context => armor_set_bonus(context))
));
const INFINITE 部分是为了让药水效果时长变为<无限>
const bonuses 部分可以很方便的设定穿戴的护甲以及要给予的药水效果