The Bug
Endermen aren't supposed to be hit by projectiles, yet the fishing line "projectile" can hook him.
Steps to Reproduce
Summon an enderman and obtain a fishing rod.
Attempt to attach the bobber from the fishing rod to the endermen and as you do this, watch the behavior of the enderman closely.
Observed Behavior
Endermen can have fishing bobbers attached to them.
Expected Behavior
Endermen would not be able to have fishing bobbers attached to them, as fishing bobbers are considered as projectiles, and it's known that endermen attempt to avoid these when necessary, so it doesn't make much sense that they don't avoid fishing bobbers.
Code Analysis
Code analysis by @unknown can be found in this comment.
Related issues
relates to
Attachments
Comments


Is this still an issue in the latest snapshot 16w44a? If so please update the affected versions.
This is an automated comment on any open or reopened issue with out-of-date affected versions.
Confirmed for 1.11.2
The following is based on a decompiled version of Minecraft 1.12 using MCP 9.40pre-1.
This happens because a fish hook doesn't do any damage to a non-player entity and therefore doesn't invoke the net.minecraft.entity.Entity.attackEntityFrom()
method which makes an enderman teleport when it gets hit by a projectile. I created a method called hitByFishHook()
in the net.minecraft.entity.monster.EntityEnderman
class which makes the enderman teleport randomly (copied the code for that from the attackEntityFrom()
method and checked if the enderman is invincible using the net.minecraft.util.DamageSource.generic
damage source as it is the most fitting here IMO).
/**
* Called when the entity gets hit by an EntityFishHook entity
*/
public boolean hitByFishHook() {
if(!this.isEntityInvulnerable(DamageSource.generic)) {
for (int i = 0; i < 64; ++i)
{
if (this.teleportRandomly())
{
return true;
}
}
return false;
}
else
{
return false;
}
}
I then added some lines of code to the net.minecraft.entity.projectile.EntityFishHook.onUpdate()
method, invoking the method I just created. This basically checks if the entity caught by the fish hook is an enderman and if it is, it will destroy the fish hook and teleport the enderman away.
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
// ...
if (this.field_190627_av == EntityFishHook.State.FLYING)
{
if (this.caughtEntity != null)
{
if(this.caughtEntity instanceof EntityEnderman)
{
((EntityEnderman) this.caughtEntity).hitByFishHook();
this.setDead();
}
else
{
this.motionX = 0.0D;
this.motionY = 0.0D;
this.motionZ = 0.0D;
this.field_190627_av = EntityFishHook.State.HOOKED_IN_ENTITY;
return;
}
}
// ...
}
else
{
// ...
}
// ...
}
As always, this might not be the best solution as it's basically just a small hotfix for this issue, but I think it gives one an idea of why this isn't working as intended and how it could be fixed. 🙂

Confirmed for 18w30b

Confirmed for 18w32a

Confirmed for 1.13.1-pre1

Confirmed for 20w29a
Can confirm in 20w48a.
Can confirm in 21w05b.
Can confirm in 21w06a. Video attached.
Can confirm in 21w11a.
Can confirm in 21w16a.
Can confirm in 21w17a.
Can confirm in 1.17.
Can confirm in 1.17.1.
Can confirm this behavior in 21w40a. Here are some extra details regarding this problem.
The Bug:
Endermen can have fishing bobbers attached to them.
Steps to Reproduce:
Summon an enderman and obtain a fishing rod.
Attempt to attach the bobber from the fishing rod to the endermen and as you do this, watch the behavior of the enderman closely.
Observed Behavior:
Endermen can have fishing bobbers attached to them.
Expected Behavior:
Endermen would not be able to have fishing bobbers attached to them, as fishing bobbers are considered as projectiles, and it's known that endermen attempt to avoid these when necessary, so it doesn't make much sense that they don't avoid fishing bobbers.
Can confirm in 1.18.2 and 22w15a.
[media]
[^8fa43e4d-a57b-47c9-8fff-c9ec8f1051df[1].png]
[media][media]