mojira.dev
MC-186119

Endermen sometimes get the wither effect when dodging wither skulls

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

  1. Summon an enderman

  2. 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

Attachments

Comments 12

gaspoweredpick

Relates to MC-178441 and MC-83051

Can confirm in 20w51a. Relates to MC-109147.

Can confirm in 21w03a.

Can confirm in 21w05b.

Can confirm in 21w07a.

2 more comments

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.

gaspoweredpick

(Unassigned)

Confirmed

Gameplay

Low

Mob behaviour

20w22a, 1.16.1, 20w29a, 1.16.2 Pre-release 1, 1.16.2 Release Candidate 1, ..., 1.20.4, 1.21, 1.21.1, 1.21.3, 1.21.4

Retrieved