Mojira Archive
MC-47699

Blazes are able to see a player through blocks

The bug

When the player attacks a blaze, nearby blazes behind solid walls will turn hostile and shoot at the player as if the wall wasn't there. Those blazes also continue to attack when the player has switched to Creative mode, whereas all blazes that initially had line-of-sight to the player will stop attacking.

Code analysis

The following analysis is based on a decompiled version of Minecraft using MCP 9.40pre-1 with MC 1.12.2 mappings (guide by [Mod] Pokechu22 here)

As per net.minecraft.entity.monster.EntityBlaze.initEntityAI(), a blaze's entityCallsForHelp boolean in the net.minecraft.entity.ai.EntityAIHurtByTarget class is always set to true, which means that it will alert other blaze entities within its followRange as soon as it gets attacked. The method which is called when a blaze wants to alert their fellow blazes is net.minecraft.entity.ai.EntityAIHurtByTarget.alertOthers().

This method, however, does not check if there are any blocks in between the attacking entity and the alerted blaze. So, I quickly made a hacky for-loop to check if there are any blocks other than air in between the entities' coordinates. Albeit I absolutely do not recommend to use this code as it is wacky as hell and does not consider all blocks within the view of the alerted blaze, it does a decent job in showing what the issue is – so I'll post it here anyway if anyone wants to test this.