Mojira Archive
MC-696

Pets disobeying sit commands by helping player when attacked and within a certain radius

The bug

When the owner of a sitting pet is attacked within a 12 meters radius around the pet it stands up. For wolves this could be intended since they can help their owner, however often if not always the owner made them sit on purpose to not accidentally hit them or be pushed of blocks by them while fighting. But for pets which cannot attack, like ocelots or parrots, this behavior makes no sense.

How to reproduce

  1. Tame a parrot and make it sit
  2. Spawn a monster within a 12 meters radius from the parrot and let it damage you
    → The parrot starts flying

Code analysis

Based on 1.12 decompiled using MCP 9.40 PRE 1

The method net.minecraft.entity.ai.EntityAISit.shouldExecute() cancels sitting if the owner is within 12 meters and net.minecraft.entity.EntityLivingBase.getAITarget() does not return null.