From 413f381dccdda56021ae70bbc4bc2cd5aff5fc2a Mon Sep 17 00:00:00 2001 From: kotyaralih <62548070+kotyaralih@users.noreply.github.com> Date: Sun, 5 Dec 2021 07:23:38 -0800 Subject: [PATCH] Says "no" to teleport hacks! --- src/Player.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Player.php b/src/Player.php index 699f8b2b..80d04d95 100644 --- a/src/Player.php +++ b/src/Player.php @@ -1475,15 +1475,16 @@ class Player{ } if(($this->entity instanceof Entity) and $data["counter"] > $this->lastMovement){ $this->lastMovement = $data["counter"]; + $newPos = new Vector3($data["x"], $data["y"], $data["z"]); if($this->forceMovement instanceof Vector3){ - if($this->forceMovement->distance(new Vector3($data["x"], $data["y"], $data["z"])) <= 0.7){ + if($this->forceMovement->distance($newPos) <= 0.7){ $this->forceMovement = false; }else{ $this->teleport($this->forceMovement, $this->entity->yaw, $this->entity->pitch, false); } } $speed = $this->entity->getSpeedMeasure(); - if($this->blocked === true or ($this->server->api->getProperty("allow-flight") !== true and (($speed > 9 and ($this->gamemode & 0x01) === 0x00) or $speed > 20)) or $this->server->api->handle("player.move", $this->entity) === false){ + if($this->blocked === true or ($this->server->api->getProperty("allow-flight") !== true and (($speed > 9 and ($this->gamemode & 0x01) === 0x00) or $speed > 20 or $this->entity->distance($newPos) > 7)) or $this->server->api->handle("player.move", $this->entity) === false){ if($this->lastCorrect instanceof Vector3){ $this->teleport($this->lastCorrect, $this->entity->yaw, $this->entity->pitch, false); } @@ -1491,7 +1492,7 @@ class Player{ console("[WARNING] ".$this->username." moved too quickly!"); } }else{ - $this->entity->setPosition(new Vector3($data["x"], $data["y"], $data["z"]), $data["yaw"], $data["pitch"]); + $this->entity->setPosition($newPos, $data["yaw"], $data["pitch"]); } } break;