Fixed #186 players not teleporting due to speed check

This commit is contained in:
Shoghi Cervantes Pueyo 2013-04-05 12:41:05 +02:00
parent 93cfa035d4
commit 8405c74b42
2 changed files with 12 additions and 5 deletions

View File

@ -475,7 +475,7 @@ class Player{
));
}
public function teleport(Vector3 $pos, $yaw = false, $pitch = false){
public function teleport(Vector3 $pos, $yaw = false, $pitch = false, $terrain = true){
if($this->entity instanceof Entity){
if($yaw === false){
$yaw = $this->entity->yaw;
@ -486,10 +486,13 @@ class Player{
$this->entity->fallY = false;
$this->entity->fallStart = false;
$this->entity->setPosition($pos->x, $pos->y, $pos->z, $yaw, $pitch);
$this->entity->resetSpeed();
$this->entity->updateLast();
$this->entity->calculateVelocity();
$this->orderChunks();
$this->getNextChunk();
if($terrain === true){
$this->orderChunks();
$this->getNextChunk();
}
}
$this->dataPacket(MC_MOVE_PLAYER, array(
"eid" => 0,
@ -790,7 +793,7 @@ class Player{
$this->lastMovement = $data["counter"];
$speed = $this->entity->getSpeed();
if($this->blocked === true or ($speed > 5 and $this->gamemode !== CREATIVE) or $speed > 12 or $this->server->api->handle("player.move", $this->entity) === false){
$this->teleport(new Vector3($this->entity->x, $this->entity->y, $this->entity->z), $this->entity->yaw, $this->entity->pitch);
$this->teleport(new Vector3($this->entity->x, $this->entity->y, $this->entity->z), $this->entity->yaw, $this->entity->pitch, false);
}else{
$this->entity->setPosition($data["x"], $data["y"], $data["z"], $data["yaw"], $data["pitch"]);
}

View File

@ -545,7 +545,11 @@ class Entity extends stdClass{
}
return false;
}
public function resetSpeed(){
$this->speedMeasure = array(0, 0, 0, 0, 0);
}
public function getSpeed(){
return array_sum($this->speedMeasure) / count($this->speedMeasure);
}