From 099bedf8ee31d2750401eca60e683cbd0cd14fa6 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sun, 9 Jun 2013 13:37:27 +0200 Subject: [PATCH] New speed limit --- src/Player.php | 4 ++-- src/world/Entity.php | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Player.php b/src/Player.php index dfca8c5ac..c239ebd32 100644 --- a/src/Player.php +++ b/src/Player.php @@ -1150,8 +1150,8 @@ class Player{ } if(($this->entity instanceof Entity) and $data["counter"] > $this->lastMovement){ $this->lastMovement = $data["counter"]; - $speed = $this->entity->getSpeed(); - if($this->blocked === true or ($this->server->api->getProperty("allow-flight") !== true and (($speed > 6 and ($this->gamemode & 0x01) === 0x00) or $speed > 15)) or $this->server->api->handle("player.move", $this->entity) === false){ + $speed = $this->entity->speed; + if($this->blocked === true or ($this->server->api->getProperty("allow-flight") !== true and (($speed > 7 and ($this->gamemode & 0x01) === 0x00) or $speed > 15)) 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); } diff --git a/src/world/Entity.php b/src/world/Entity.php index 8c4c9566a..595e731f5 100644 --- a/src/world/Entity.php +++ b/src/world/Entity.php @@ -501,7 +501,7 @@ class Entity extends Position{ } $this->calculateVelocity(); - if($this->speed <= 5 or ($this->speed <= 12 and ($this->player->gamemode & 0x01) === 0x01)){ + if($this->speed <= 7 or ($this->speed <= 15 and ($this->player->gamemode & 0x01) === 0x01)){ $this->player->lastCorrect = new Vector3($this->last[0], $this->last[1], $this->last[2]); } } @@ -782,6 +782,10 @@ class Entity extends Position{ } public function getSpeed(){ + return $this->speed; + } + + public function getSpeedMeasure(){ return array_sum($this->speedMeasure) / count($this->speedMeasure); }