Files
fuwuduan/kubejs/server_scripts/eeeabsmobs_frenzy.js
2025-10-20 07:39:17 +00:00

64 lines
2.3 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 检查玩家背包变化时遍历狂乱药水并修改NBT为力量效果仅非创造模式
PlayerEvents.inventoryChanged(event => {
const player = event.player
// 检查玩家是否为创造模式,如果是则跳过处理
if (player.isCreative()) {
return
}
// 遍历玩家背包中的所有物品
player.inventory.allItems.forEach(item => {
// 检测普通狂乱药水
if (item.id === 'minecraft:potion' &&
item.nbt &&
item.nbt.toString().includes('eeeabsmobs:frenzy')) {
console.info(`发现狂乱药水修改NBT为力量2效果 (玩家: ${player.name})`)
// 直接修改物品的NBT为力量2药水
item.nbt = {
Potion: "minecraft:strong_strength"
}
}
// 检测喷溅型狂乱药水
if (item.id === 'minecraft:splash_potion' &&
item.nbt &&
item.nbt.toString().includes('eeeabsmobs:frenzy')) {
console.info(`发现喷溅型狂乱药水修改NBT为喷溅型力量2效果 (玩家: ${player.name})`)
// 直接修改物品的NBT为喷溅型力量2药水
item.nbt = {
Potion: "minecraft:strong_strength"
}
}
// 检测滞留型狂乱药水
if (item.id === 'minecraft:lingering_potion' &&
item.nbt &&
item.nbt.toString().includes('eeeabsmobs:frenzy')) {
console.info(`发现滞留型狂乱药水修改NBT为滞留型力量2效果 (玩家: ${player.name})`)
// 直接修改物品的NBT为滞留型力量2药水
item.nbt = {
Potion: "minecraft:strong_strength"
}
}
// 检测狂乱药箭
if (item.id === 'minecraft:tipped_arrow' &&
item.nbt &&
item.nbt.toString().includes('eeeabsmobs:frenzy')) {
console.info(`发现狂乱药箭修改NBT为力量2药箭 (玩家: ${player.name})`)
// 直接修改物品的NBT为力量2药箭
item.nbt = {
Potion: "minecraft:strong_strength"
}
}
})
})