//瘟疫attribute效果实现
NativeEvents.onEvent($LivingHurtEvent, event => {
    if (event.source.player && !event.entity.isPlayer()) {
        let player = event.source.player
        let entity = event.entity
        let type = event.getSource().getType().toString();
        if (type != 'player' && type != 'mob' && type != 'arrow') return

        if (player.getAttackStrengthScale(0.5) < 0.9) return

        let pestilence_amount = player.getAttributeTotalValue('kubejs:pestilence')
        if (pestilence_amount == 0) return

        player.server.scheduleInTicks(1, () => {
            simpleAttackEntity(true, player, entity, 'pestilence', pestilence_amount)
        })

    }
})

//瘟疫减少回血效果实现
NativeEvents.onEvent($LivingHurtEvent, event => {
    if (event.source.player && !event.entity.isPlayer()) {
        let entity = event.entity
        let amount = event.amount
        let type = event.getSource().getType().toString();
        if (type == 'pestilence') {
            entity.modifyAttribute('attributeslib:healing_received', 'pestilence_redeces_treat', -amount / 1000, 'addition')
        }
    }
})

NativeEvents.onEvent($LivingHurtEvent, event => {
    if (event.source.player && !event.entity.isPlayer()) {
        let player = event.source.player
        let entity = event.entity
        let type = event.getSource().getType().toString();
        if (type != 'player' && type != 'mob' && type != 'arrow') return

        if (player.getAttackStrengthScale(0.5) < 0.9) return

        player.server.scheduleInTicks(1, () => {
            let amount = player.getAttributeTotalValue('kubejs:fire_damage')
            if (amount == 0) return
            simpleAttackEntity(true, player, entity, 'kubejs_fire_damage', amount)
            let blazing_steel_level = simpleGetTetraEffectLevel(player.getMainHandItem(), 'blazing_steel')
            entity.setRemainingFireTicks(entity.getRemainingFireTicks() + 10 * amount * (1 + blazing_steel_level / 100))

        })
    }
});
