Mojira Archive
MC-85177

Guardian beam is not rendered if targeted entity is the first entity in the world

The bug

The guardian beam is not rendered if the attacked entity has the entity id 0, which is also the entity id used by the first entity in the world (usually a player).

How to reproduce

  1. Create a new "The Void" Superflat world or load a world which has not entities in it
  2. Summon a guardian
    /summon armor_stand ~ ~ ~ {Passengers:[{id:"guardian"}]}
    
  1. Switch to Survival or Adventure mode
    You should see that the beam is not rendered

Code analysis

Based on 1.11.2 decompiled using MCP 9.35 rc1

The data parameter net.minecraft.entity.monster.EntityGuardian.TARGET_ENTITY stores the entity id of the targeted entity. 0 is used as default value and to indicate that no entity is targeted. The problem is that the method net.minecraft.entity.monster.EntityGuardian.AIGuardianAttack.updateTask() directly stores the entity without increasing it by 1. Therefore entities with entity id 0 are treated as not targeted.

Note: Possible other solutions are to start the entity ids always at 1 or to introduce new optional data parameters.