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:
Build a platform high in the air
Summon wolf on top of it
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:
Attachments
Comments


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.
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.
Confirmed for 19w14b

Confirmed for 1.14.

Yes, wolves should not take fall damage after teleporting. My wolves died this way, it was so sad. ).;

Confirmed in 1.16.1 and 20w29a.

Probably has something to do with MC-14167
Can confirm in 20w48a.
Can confirm in 21w03a.
Can confirm in 21w05b.
Can confirm in 21w06a.
Can confirm in 21w08b. Video attached.
Can confirm in 1.17.1.

Can confirm in 1.19.3.

still in 23w13a and 1.19.4

Can confirm in 23w33a

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:
Check if the entity is not a flying entity (no need to reset fall damage of an entity that cannot take fall damage)
Check if the entity has at least fallen > 3.0 blocks distance downward (the maximum distance an entity can fall before taking fall damage)
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.