Mojira Archive
MC-258438

Pets can look at their owners from anywhere in the world

Description

This issue could be considered fairly public by now, since it was covered by youtubers like LiveOverflow, still going to mark it as secret since this does involve leaking coordinates.

Pets can look at their owners, regardless of whether they are thousands of blocks away. This can be abused by monitoring where the pet is looking, then transporting it, and then monitoring again to triangulate the position of the owner.

Code analysis

The issue lies in the `FollowOwnerGoal` goal. First, if we look at the `canUse` and the `canContinueToUse` method, we can see the goal is activated when the owner is online, not in spectator mode, the pet is not sitting and the owner is the minimum distance away. The goal will be continued to be executed as long as the pet isn't sitting, hasn't finished walking to its owner and is not further away than the stop distance. This will lead to the goal running for just one tick when the owner is far away.

 

   @Override
   public boolean canUse() {
      LivingEntity livingEntity = this.tamable.getOwner();
      if (livingEntity == null) {
         return false;
      } else if (livingEntity.isSpectator()) {
         return false;
      } else if (this.tamable.isOrderedToSit()) {
         return false;
      } else if (this.tamable.distanceToSqr(livingEntity) < (double)(this.startDistance * this.startDistance)) {
         return false;
      } else {
         this.owner = livingEntity;
         return true;
      }
   }  
   @Override
   public boolean canContinueToUse() {
      if (this.navigation.isDone()) {
         return false;
      } else if (this.tamable.isOrderedToSit()) {
         return false;
      } else {
         return !(this.tamable.distanceToSqr(this.owner) <= (double)(this.stopDistance * this.stopDistance));
      }
   }

This behaviour of running the goal for just one tick is probably intentional to allow the pet to teleport to its owner, regardless of how far away it is, as we can see in the tick method:

 

   @Override
   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.isLeashed() && !this.tamable.isPassenger()) {
            if (this.tamable.distanceToSqr(this.owner) >= 144.0) {
               this.teleportToOwner();
            } else {
               this.navigation.moveTo(this.owner, this.speedModifier);
            }         
         }
      }
   } 

As we can see, the pet will look at the player and then, assuming it's not leashed and not in a vehicle, either teleport to the owner or try to path to it, if it is close enough. The problem here is that the pet will always look towards its owner, regardless of whether it's teleported or starts walking towards it.

 

This can be abused by trapping the pet in a vehicle and moving it around, triangulating the position it is looking at.

A possible fix would be to add a maximum look distance, which is what I've done for Paper. Another possible fix would be to move the look call next to the moveTo call.

 

Fixed

Noah van der Aa

[Mojang] Gegy

2022-12-10, 06:08 PM

2023-02-15, 01:21 PM

2023-02-15, 01:21 PM

3

5

Plausible

Important

Platform

Mob behaviour

1.19.3

23w07a