mojira.dev
MC-146985

Helmeted phantoms will still burn under the sunlight

As we know, if a undead(burn under the sunlight) wear a helmet, it won't burn under the sunlight, but this feature is not working for phantoms, even if a phantom wear a helmet(it don't display but it's useful), it will still burn under the sunlight. This issue doesn't happen to zombies, skeletons, strays, drowned or zombie villagers
The command of the helmeted phantom is:

/summon minecraft:phantom ~ ~ ~ {ArmorItems:[{},{},{},{id:"jack_o_lantern",Count:1b}]}

Linked issues

Attachments

Comments 7

  1. Phantoms have their whole body exposed to the sum, so it wouldn't make sense for just the helmet to protect them.

  2. If you want them to survive in day, give them fire resistance.

  3. I think this is a feature request, not a bug.

@Nathan Jensen
1.Other helmeted undead's arms also exposed to the sun, why won't them burn at all under the sunlight, why can helmeted phantoms rise their own armor vaule.
2.If you think so, most bugs will needn't to fix.
3.Due to Minecraft logic, Other armored mobs that don't display armors, their armors will still be effective(armor vaule, enchantments and modification of attributes and other armor feature), but phantoms are different, so this a bug. This is Minecraft, not real life, don't comment with experience of real life

Helmeted phantom is not intended

Yes, it is doing something that was not intended.

Heh, you were very dedicated to try that : D

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

Code Analysis:

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

net.minecraft.world.entity.monster.Phantom.java

public class Phantom extends FlyingMob implements Enemy {
   ...
   public void aiStep() {
      if (this.isAlive() && this.isSunBurnTick()) {
         this.setSecondsOnFire(8);
      }

      super.aiStep();
   }
   ...

If we look at the above class, we can see that no checks are carried out to see whether or not a phantom is wearing a helmet on their head, before receiving damage from exposure to the sun.

Potential Fix:

Simply adding some lines of code to check whether or not a phantom is wearing a helmet on their head before receiving damage from the sun, should resolve this problem.

The correct piece of code within its class should look something like the following:

net.minecraft.world.entity.monster.Phantom.java

public class Phantom extends FlyingMob implements Enemy {
   ...
   public void aiStep() {
      if (this.isAlive()) {
         boolean flag = this.isSunSensitive() && this.isSunBurnTick();
         if (flag) {
            ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD);
            if (!itemstack.isEmpty()) {
               if (itemstack.isDamageableItem()) {
                  itemstack.setDamageValue(itemstack.getDamageValue() + this.random.nextInt(2));
                  if (itemstack.getDamageValue() >= itemstack.getMaxDamage()) {
                     this.broadcastBreakEvent(EquipmentSlot.HEAD);
                     this.setItemSlot(EquipmentSlot.HEAD, ItemStack.EMPTY);
                  }
               }

               flag = false;
            }

            if (flag) {
               this.setSecondsOnFire(8);
            }
         }
      }

      super.aiStep();
   }
   ...

Can confirm in 1.19.

BLack_Tea_RGO

(Unassigned)

Confirmed

Entities

Minecraft 1.13.2, Minecraft 19w12b, Minecraft 19w13a, Minecraft 19w13b, Minecraft 19w14a, ..., 24w05b, 1.21, 1.21.3, 1.21.4, 25w02a

Retrieved