BerndiVader / MythicAnimatorStands

Do some fun with ArmorStands.
4 stars 5 forks source link

AnimatorStandHandleDamage may be problems. #3

Open wu452148993 opened 6 years ago

wu452148993 commented 6 years ago
public void AnimatorStandHandleDamage(EntityDamageEvent e) {
    if (e.isCancelled()) return;
    if (e.getEntity().getType().equals(EntityType.ARMOR_STAND) && e.getEntity().hasMetadata("asa")) {
        ArmorStandAnimator asa = ArmorStandUtils.getAnimatorInstance(BukkitAdapter.adapt(e.getEntity()));
        if (!asa.hasAI()) return;
        e.setCancelled(true);
        if (e instanceof EntityDamageByEntityEvent && !asa.isDying) {
            EntityDamageByEntityEvent ee = (EntityDamageByEntityEvent) e;
            AbstractEntity attacker = this.getAttacker(ee.getDamager());
            if (!attacker.isPlayer()) {
                asa.aiMob.getLivingEntity().damage(e.getDamage(), ee.getDamager());
            }
        }
    }
}

My English is poor。 When a player attacks armor armor, the damage cannot be passed to aimob. When damage is AoE from environment, aimob will be twice damaged