Mojira Archive
MC-28440

Sitting child pets teleporting to owner when growing up

The bug

Sitting child pets can teleport to their owner when they grow up but immediately appear sitting again afterwards.

How to reproduce

  1. Spawn one wolf and tame it
  2. Hold right click on the wolf while holding a wolf spawn egg to spawn baby wolves
  3. Make all wolves sit
    /entitydata @e[type=wolf] {Sitting:1b}
    
  4. Move away from the wolves
  5. Change their age so they will grow up rather fast
    /entitydata @e[type=wolf] {Age:-100}
    

    → Some wolves teleported to you

Code analysis

Based on 1.12 decompiled using MCP 9.40 PRE 1

It looks like the method net.minecraft.entity.Entity.setSize(float, float) is indirectly causing this since it is calling the method net.minecraft.entity.Entity.moveEntity(MoverType, double, double, double) without a downwards motion. This causes the onGround field to be set to false which then causes the EntityAISit task to be reset.

Calling that method with the default gravity downwards motion (if the entity has gravity enabled) might result in unexpected behavior. Instead the onGround value could be restored or only motion values could be set, but this could result in different behavior as well.