这是我为了给所以饮酒作乐饮品加上一个destroy的效果的脚本,看起来给你需要的写法差不多,分享一下ItemEvents
![[呵呵]](/static/emoticons/u5475u5475.png)
.foodEaten(event => {
const { player, item } = event;
if (item
![[呵呵]](/static/emoticons/u5475u5475.png)
.hasTag('brewinandchewin:fermented_drinks')) {
const effectId = 'destroy:full_bladder';
const existing = player
![[呵呵]](/static/emoticons/u5475u5475.png)
.getEffect(effectId);
const currentLevel = existing ? existing
![[呵呵]](/static/emoticons/u5475u5475.png)
.getAmplifier() : -1; // -1 表示不存在
const newLevel = Math
![[呵呵]](/static/emoticons/u5475u5475.png)
.min(currentLevel + 1, 4); // 不存在 -> 0,存在则+1,最大4
player
![[呵呵]](/static/emoticons/u5475u5475.png)
.potionEffects
![[呵呵]](/static/emoticons/u5475u5475.png)
.add(effectId, 1200, newLevel, false, false);
}
});