// priority: 8
function curiostetraplayerhurt(event) {
    let player = event.entity;
    if (!player) return;

    // 使用工具函数获取饰品效果数据
    let curiosEffects = get_all_curios_effects(player);
    if (!curiosEffects || curiosEffects.length === 0) return;

    // 遍历所有饰品效果，执行对应策略
    curiosEffects.forEach(effect => {
        let strategy = curiostetraplayerhurtStrategies[effect.name] || curiostetraplayerhurtStrategies.default;
        strategy(event, player, effect.level, effect.name, effect.efficiency);
    });
}
const curiostetraplayerhurtStrategies = {
    //神圣
    'invincible_frames': function (event, player, effectLevel, effectname, efficiency) {
        player.invulnerableTime = player.invulnerableTime + effectLevel

    },
    //凋零合金块
    'witherite_block': function (event, player, effectLevel, effectname, efficiency) {
        // 伤害类型
        let type = event.getSource().getType().toString();
        if (type == 'explosion.player') {
            event.amount = 0
        }

    },
    //伤痛反应剂
    'absorption_boost': function (event, player, effectLevel, effectname, efficiency) {
        if (getPlayerCuriosEffectData(player, 'bio_lab').level == 0) {
            let time = player.persistentData.getInt(effectname) ?? 0;
            if (player.age - time < 20 * 60 * 30) return;
        }
        //获取营养值
        let count = player.persistentData.getInt(YingYangCount)
        if (count < 2) return
        //减少营养值
        updateYingYangCount(player, count - 1)

        player.absorptionAmount = Math.min(player.absorptionAmount + 1, effectLevel / 100 * player.getMaxHealth(),efficiency)
        player.persistentData.putInt(effectname, player.age)
    },
    // 蚀龙兽断角
    'corrosiver_broken_horn': function (event, player, effectLevel, effectname, efficiency) {
        event.amount = event.amount * 0.92;
    },
    // 灾厄旗帜投影绿宝石碎片
    'ominous_banner_projection_emerald_fragment': function (event, player, effectLevel, effectname, efficiency) {
        event.amount = event.amount * 0.95;
    },
    // 紫沙鬼婆头发
    'purple_sand_hag_hair': function (event, player, effectLevel, effectname, efficiency) {
        event.amount = event.amount * 0.92;
    },
    // 宝石恶鳞鳞片
    'gemstone_malignasaur_scale': function (event, player, effectLevel, effectname, efficiency) {
        event.amount = event.amount * 0.92;
    },
    // 沉降领主袍服碎片
    'sediment_lord_robe_pieces': function (event, player, effectLevel, effectname, efficiency) {
        event.amount = event.amount * 0.95;
    },
    // 繁兴使者花朵
    'prosperous_envoy_flower': function (event, player, effectLevel, effectname, efficiency) {
        event.amount = event.amount * 0.95;
    },
    // 明路巨兽绒毛
    'bright_land_beast_fluff': function (event, player, effectLevel, effectname, efficiency) {
        event.amount = event.amount * 0.92;
    },
    // 蛇龙执战者勋章
    'serpon_combat_executer_medal': function (event, player, effectLevel, effectname, efficiency) {
        event.amount = event.amount * 0.90
        let random = Math.random()
        if (random <= 0.25) {
            event.amount = 0
        }
    },
    'default': function (event, player, effectLevel, effectname, efficiency) {
        return
    }
}