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
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;
}
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 you reproduce this bug in 1.15.2?