mojira.dev
MC-87907

Endermen don't become aggressive when players look at their head/feet

Only looking at their torso will make them become aggressive at you.

Step to reproduce:
Go in a Survival world
Find an enderman
Stare at him.


Code analysis: https://bugs.mojang.com/browse/MC-87907?focusedCommentId=300590&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-300590

Linked issues

Comments 17

This ticket is incomplete. Please review the guidelines before reporting issues.
For technical support please use the Mojang Support Center.

--- This action was performed automagically. If you believe this was done erroneously, please :light_bulb_on: raise an issue.

Works for me after a second or so.

Weird! I did try to spawn a few and I looked at them for at least 5 seconds without getting any reaction.

Did switch to survival gamemode? Or were you in creative?

I was in survival mode, as stated in the bug report 🙂

7 more comments

Confirmed for 1.9

Still in 1.9.1-pre1

Confirmed for 1.9.2

Please link to this comment in the description

The following is based on decompiled version of Minecraft 1.9 using MCP 9.24 beta. All method and class names are the names used in the decompiled version.

It looks like the method net.minecraft.entity.monster.EntityEnderman.shouldAttackPlayer(EntityPlayer) is defining the area, which counts as looking at an Enderman as the middle of its height.

The following changes it so the Enderman becomes only aggressive when you look at its head.

/**
 * Checks to see if this enderman should be attacking this player
 */
private boolean shouldAttackPlayer(EntityPlayer player)
{
    ItemStack itemstack = player.inventory.armorInventory[3];

    if (itemstack != null && itemstack.getItem() == Item.getItemFromBlock(Blocks.pumpkin))
    {
        return false;
    }
    else
    {
        Vec3d vec3d = player.getLook(1.0F).normalize();
        // Replaced this
        //Vec3d vec3d1 = new Vec3d(this.posX - player.posX, this.getEntityBoundingBox().minY + (double)(this.height / 2.0F) - (player.posY + (double)player.getEyeHeight()), this.posZ - player.posZ);
        Vec3d vec3d1 = new Vec3d(this.posX - player.posX, this.getEntityBoundingBox().minY + (double)this.getEyeHeight() - (player.posY + (double)player.getEyeHeight()), this.posZ - player.posZ);
        double d0 = vec3d1.lengthVector();
        vec3d1 = vec3d1.normalize();
        double d1 = vec3d.dotProduct(vec3d1);
        return d1 > 1.0D - 0.025D / d0 ? player.canEntityBeSeen(this) : false;
    }
}

This has been around forever. I thought it was just a design decision! 😛

Thomas Imbert

migrated

Confirmed

mob

Minecraft 15w36c, Minecraft 15w44b, Minecraft 16w06a, Minecraft 1.9, Minecraft 1.9.1 Pre-Release 1, Minecraft 1.9.1, Minecraft 1.9.2

Minecraft 1.9.3 Pre-Release 2

Retrieved