apace100/apoli

Damage-modifying power types will always play the hurt animation for players, regardless of if the specified damage condition is true or not

Closed this issue · 0 comments

This issue is caused by using the PowerHolderComponent#getPowers method in the PlayerEntityMixin.java class, which does not provide a way of specifying a predicate to evaluate the the damage condition of the powers:

if(source.getAttacker() != null) {
if(!source.isProjectile()) {
hasModifyingPower = PowerHolderComponent.getPowers(source.getAttacker(), ModifyDamageDealtPower.class).size() > 0;
} else {
hasModifyingPower = PowerHolderComponent.getPowers(source.getAttacker(), ModifyProjectileDamagePower.class).size() > 0;
}
}
hasModifyingPower |=
PowerHolderComponent.getPowers(this, ModifyDamageTakenPower.class).size() > 0;


This issue can be fixed by using the PowerHolderComponent#hasPower method and providing a predicate that would evaluate the damage condition of the powers instead:

if (source.getAttacker() != null) {
    if(!source.isProjectile()) {
        hasModifyingPower = PowerHolderComponent.hasPower(source.getAttacker(), ModifyDamageDealtPower.class, p -> p.doesApply(source, amount, this));
    }
    else {
        hasModifyingPower = PowerHolderComponent.hasPower(source.getAttacker(), ModifyProjectileDamagePower.class, p -> p.doesApply(source, amount, this));
    }
}

hasModifyingPower |= PowerHolderComponent.hasPower(this, ModifyDamageTakenPower.class, p -> p.doesApply(source, amount));