let EnergyBarReference = Java.loadClass('net.threetag.palladium.power.energybar.EnergyBarReference');
let SHADOW_FORM_BAR_REF = new EnergyBarReference('arrzenhanced:power_negation', 'shadow_form');

EntityEvents.hurt(event => {
    var source = event.source.actual;
    var target = event.entity;

    // Ensure the source is an entity (not a block, projectile, etc.)
    if (!source || !source.isLiving() || !target || !target.isLiving()) return;

    if (palladium.superpowers.hasSuperpower(source, 'arrzenhanced:power_negation')) {
        if (source.mainHandItem.id != 'arrzenhanced:deadzone_dagger') {return}
        var shadowFormBar = SHADOW_FORM_BAR_REF.getEntry(source)
        if (shadowFormBar.get() == shadowFormBar.getMax()) {return}
        shadowFormBar.add(100)
    }
})
