1.17.1 EntityDamageByEntityEvent - setDamage(0) doesn't work for Healing arrows

Discussion in 'Spigot Plugin Development' started by Noni, Oct 12, 2021.

  1. The following code snippet cancels hit damage of all kinds of arrows EXCEPT for those with Instant Healing II effect. Why is that?
    Code (Text):
    @EventHandler
        void oneEntityDamageByEntity(EntityDamageByEntityEvent e) {
            if(e.getDamager().getType() != EntityType.ARROW) return;
            e.setDamage(0);
    }
    Video:
     
    #1 Noni, Oct 12, 2021
    Last edited: Oct 12, 2021
  2. Because its Healing?
    are you aware that you are listening EntityDamageByEntityEvent
     
  3. Tipped arrows apply a potion effect, they do not do the damage directly.
     
  4. They deal damage on hit and apply the potion effect afterwards.

    Yes I am aware of that. When using the code snippet I posted, all arrows and tipped arrows deal zero damage on impact.
    The Instant Healing II tipped arrows however deal their usual damage when hitting a target.
     
  5. Test it on a player, you are hitting an undead mob with a healing potion, that's the reason they got damage
     
    • Informative Informative x 1