mojira.dev
MC-188700

Wearing a wither skeleton skull doesn't affect the range of wither skeletons' vision

The bug

When wearing a creeper head, zombie head, or skeleton skull it decreases their vision by 50%, but wearing wither skeleton skulls have no effect.

Code analysis

Code analysis by @unknown can be found in this comment.

Attachments

Comments 8

Can you reproduce this bug in 1.15.2?

Can confirm that this is still an issue in 20w51a.

Can confirm in 21w03a.

Can confirm in 1.16.5.

I can also confirm this behavior in 1.18.1. Here's a code analysis regarding this issue along with a fix.

Code Analysis:

The following is based on a decompiled version of Minecraft 1.19.2 using MCP-Reborn.

net.minecraft.world.entity.LivingEntity.java

public abstract class LivingEntity extends Entity {
   ...
   public double getVisibilityPercent(@Nullable Entity entity) {
      double d0 = 1.0D;
      ...
      if (entity != null) {
         ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD);
         EntityType<?> entitytype = entity.getType();
         if (entitytype == EntityType.SKELETON && itemstack.is(Items.SKELETON_SKULL)
                 || entitytype == EntityType.ZOMBIE && itemstack.is(Items.ZOMBIE_HEAD)
                 || entitytype == EntityType.CREEPER && itemstack.is(Items.CREEPER_HEAD)) {
            d0 *= 0.5D;
         }
      }
      return d0;
   }
   ...

If we look at the above class, we can see that the detection radius of a skeleton, zombie, or creeper is halved when wearing their respective skull/head. The game doesn't check if the entity type is a wither skeleton, and if so, whether the player is wearing a wither skeleton skull or not, before allowing its detection radius to be halved, therefore resulting in this problem occurring.

Fix:

Simply altering the appropriate existing "if" statement within this piece of code to check if the entity type is a wither skeleton, and if so, whether the player is wearing a wither skeleton skull or not, before allowing its detection radius to be halved, will resolve this problem.

Current "if" statement:

if (entitytype == EntityType.SKELETON && itemstack.is(Items.SKELETON_SKULL) 
        || entitytype == EntityType.ZOMBIE && itemstack.is(Items.ZOMBIE_HEAD) 
        || entitytype == EntityType.CREEPER && itemstack.is(Items.CREEPER_HEAD)) {
   d0 *= 0.5D;
}

Fixed "if" statement:

if (entitytype == EntityType.SKELETON && itemstack.is(Items.SKELETON_SKULL) 
        || entitytype == EntityType.ZOMBIE && itemstack.is(Items.ZOMBIE_HEAD) 
        || entitytype == EntityType.CREEPER && itemstack.is(Items.CREEPER_HEAD) 
        || entitytype == EntityType.WITHER_SKELETON && itemstack.is(Items.WITHER_SKELETON_SKULL)) {
   d0 *= 0.5D;
}

Can confirm in 1.19.2.

Following on from my code analysis, I've double-checked my proposed fix and I can confidently confirm that it's fully functioning and works as expected, so I've attached two screenshots to this report, one of which shows the current code and the other that shows the fixed code. I feel this information may be quite insightful hence my reasoning for providing it. 🙂

[media][media]

Can confirm in 1.20.3 Pre-Release 1.One note for the code analysis, this behavior was properly added to piglins and piglin brutes when the piglin head was added.

SlushFiend

(Unassigned)

Confirmed

Mob behaviour, Player

1.15.2, 1.16 Pre-release 4, 20w51a, 21w03a, 1.16.5, 1.17, 1.17.1 Release Candidate 1, 1.17.1, 1.18.1, 1.19.2

Retrieved