The bug
When an enderman avoids a wither skull, they won't take damage directly from the skull, but they still might get the wither effect.
Reproduction steps
Summon an enderman
Summon a wither skull flying towards the enderman
/execute at @e[type=enderman] run summon wither_skull ~-2 ~2 ~ {power:[0.1d,0d,0d]}
❌ The enderman got the wither effect
Code analysis
Code analysis by @unknown can be found in this comment.
Linked issues
relates to 4
Attachments
Comments
Can confirm in 20w51a. Relates to MC-109147.
Can confirm in 21w03a.
Can confirm in 21w05b.
Can confirm in 21w07a.
Can confirm in 1.17.
Can confirm in 1.17.1.
Can confirm in 1.18.1.
/execute at @e[type=minecraft:enderman] run summon minecraft:wither_skull ~-3 ~2 ~ {NoGravity:1b,Motion:[0.5,0.0,0.0]}

In 22w05a

This bug is very simple. Basically, the enderman damage() method returns the wrong value when evading damage
Code Analysis - (yarn 22w17a)
net.minecraft.entity.mob.EndermanEntity.java
public boolean damage(DamageSource source, float amount) {
if (this.isInvulnerableTo(source)) {
return false;
} else if (source instanceof ProjectileDamageSource) {
Entity entity = source.getSource();
boolean hurt = false;
if (entity instanceof PotionEntity) {
hurt = this.damageFromPotion(source, (PotionEntity)entity, amount);
}
for(int i = 0; i < 64; ++i) {
if (this.teleportRandomly()) {
return true; // Return true which means it got damaged. Even though thats not the case
// return hurt; // This is what it should be to fix the problem
}
}
return hurt;
} else {
// ...
}
}
So funnily enough using the command:
/execute at @e[type=minecraft:enderman] run summon minecraft:wither_skull ~-3 ~2 ~ {NoGravity:1b,Motion:[0.5,0.0,0.0]}
Actually should be a separate bug. Since the wither skull applies the damage as a magic attack if it does not have an owner.
Using a real wither, my fix actually works correctly. Working Fix
Can confirm in 1.19.
Can confirm in 1.19.2.
Relates to MC-178441 and MC-83051