I use this: PHP: $entity = $player->getLevel()->getEntity($this->pet[$player->getName()]);$speed = 1;$x = $player->x;$y = $player->y;$z = $player->z;if($x ** 2 + $z ** 2 < 0.7){$motionX = 0;$motionZ = 0;}else{$diff = abs($x) + abs($z);$motionX = $speed * 0.15 * ($x / $diff);$motionZ = $speed * 0.15 * ($z / $diff);}$entity->move($motionX, $y, $motionZ);$entity->level->addEntityMotion($entity->chunk->getX(),$entity->chunk->getZ(),$entity->getId(),$motionX,0,$motionZ);$entity->updateMovement();
PHP: $entity = $player->getLevel()->getEntity($this->ID);if($entity != NULL) {$speed = 1;$x = $player->x;$y = $player->y;$z = $player->z;if($x ** 2 + $z ** 2 < 0.7){$motionX = 0;$motionZ = 0;}else{$diff = abs($x) + abs($z);$motionX = $speed * 0.15 * ($x / $diff);$motionZ = $speed * 0.15 * ($z / $diff);}$entity->level->addEntityMotion($x,$z,$entity->getId(),$motionX,0,$motionZ);