mojira.dev
MC-109060

When tamed animals fall from a high place, they are teleported to the player

When tamed animals fall from high place, they can teleport to the player but not reset their fall distance, leading to death.

Steps to Reproduce:

  1. Build a platform high in the air

  2. Summon wolf on top of it

  3. Punch the wolf off
    →❌ It will teleport to the player and take a lot of damage/die because of fall damage.

Code analysis

Refer to this comment:

this comment.

Attachments

Comments 23

Still present in 1.13.1.

Confirmed for 1.13.2-pre2.

Present in 1.13.2.

Tamed wolves are particularly strange. They will fall, die from fall damage while falling but then teleport to the player with low health.

gaspoweredpick

Confirmed for 19w12b. I think the real bug here is that wolves take fall damage after teleporting, which doesn't happen when players are falling and then use an ender pearl. The same should happen with players when eating chorus fruit, which is why this might relate to MC-112133.

gaspoweredpick

Confirmed for 19w14b

13 more comments

I feel like pet teleportation should simply reset fall damage the way other forms of survival teleportation (eg. ender pearls) do. That's the intuitive mechanic, and it makes the came more fun as a result.

Code Analysis (MCP):

Tamed mobs teleporting to their owners is handled inside the 'tick()' method of the FollowOwnerGoal class. Here, the game checks only the distanceToSqr of the owner before teleporting the Cat or Wolf pet to the player. There is no behavior as described in the issue to handle if the entity is falling, and how far.

net.minecraft.world.entity.ai.goal (1.20.1 Mojang Mappings)
public void tick() {
      this.tamable.getLookControl().setLookAt(this.owner, 10.0F, (float)this.tamable.getMaxHeadXRot());
      if (--this.timeToRecalcPath <= 0) {
         this.timeToRecalcPath = this.adjustedTickDelay(10);
         if (this.tamable.distanceToSqr(this.owner) >= 144.0D) {
            this.teleportToOwner();
         } else {
            this.navigation.moveTo(this.owner, this.speedModifier);
         }

      }
   }

Possible Fix:

To fix this behavior, the following can be done:

  1. Check if the entity is not a flying entity (no need to reset fall damage of an entity that cannot take fall damage)

  2. Check if the entity has at least fallen > 3.0 blocks distance downward (the maximum distance an entity can fall before taking fall damage)

  3. If both checks are true, reset the entities fall damage.
    (If I have missed any additional checks, let me know and I will update it)

    public void tick() {
          this.tamable.getLookControl().setLookAt(this.owner, 10.0F, (float)this.tamable.getMaxHeadXRot());
          if (--this.timeToRecalcPath <= 0) {
             this.timeToRecalcPath = this.adjustedTickDelay(10);
             if (this.tamable.distanceToSqr(this.owner) >= 144.0D) {
                if (!(this.tamable instanceof FlyingAnimal) && this.tamable.fallDistance > 3.0F) {
                   this.tamable.resetFallDistance();
                }
                this.teleportToOwner();
             } else {
                this.navigation.moveTo(this.owner, this.speedModifier);
             }
    
          }
       }

The fix provides the following expected behavior:

[media]

This issue also applies to 1.20.1

Affects 1.20.2

Affects 1.21. I would like to request ownership of this issue to add the code analysis I previously provided directly to the report. The original owner has been inactive since 2017.

송민제

[Mod] Jingy

(Unassigned)

Confirmed

Mob behaviour

cat, pet, wolf

Minecraft 1.10.2, Minecraft 16w42a, Minecraft 1.13.1, Minecraft 1.13.2-pre2, Minecraft 1.13.2, ..., 23w13a, 23w33a, 1.20.2, 1.21, 25w03a

Retrieved