var BuiltInRegistries = Java.loadClass("net.minecraft.core.registries.BuiltInRegistries")

EntityEvents.hurt(event => {
    var { entity, source } = event
    let attackingEntity = source.player
    //
    if (entity.type == "minecraft:player") {
        let allPowers = palladium.powers.getPowerIds(entity),
        hasPowers = false,
        metConditions = false
        allPowers.forEach(power => {
            if (palladium.superpowers.hasSuperpower(entity, power) == true) {hasPowers = true}
        })
        if (source.type().msgId().includes('explosion')) { // exploded
            if (
                (entity.mainHandItem.id == "arrzenhanced:fatherbox") ||
                (entity.offHandItem.id == "arrzenhanced:fatherbox")
            ) {
                metConditions = true
            }
            
            if (metConditions && !hasPowers) {
                entity.potionEffects.add('minecraft:blindness', 3*20, 100, false, false)
                entity.potionEffects.add('minecraft:weakness', 3*20, 100, false, false)
                if (entity.mainHandItem.id == "arrzenhanced:fatherbox") {
                    entity.mainHandItem.count--
                }
                if (entity.offHandItem.id == "arrzenhanced:fatherbox") {
                    entity.offHandItem.count--
                }
                palladium.superpowers.addSuperpower(entity, "arrzenhanced:warpwave_manipulation")
            }
        }
    }
})