Set max movement distance, disallows teleport cheat

This commit is contained in:
Shoghi Cervantes 2014-02-09 05:30:15 +01:00
parent 072d0589d2
commit 5c1550e116

View File

@ -1505,15 +1505,16 @@ class Player{
}
if(($this->entity instanceof Entity) and $packet->messageIndex > $this->lastMovement){
$this->lastMovement = $packet->messageIndex;
$newPos = new Vector3($packet->x, $packet->y, $packet->z);
if($this->forceMovement instanceof Vector3){
if($this->forceMovement->distance(new Vector3($packet->x, $packet->y, $packet->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);
}
@ -1521,7 +1522,7 @@ class Player{
console("[WARNING] ".$this->username." moved too quickly!");
}
}else{
$this->entity->setPosition(new Vector3($packet->x, $packet->y, $packet->z), $packet->yaw, $packet->pitch);
$this->entity->setPosition($newPos, $packet->yaw, $packet->pitch);
}
}
break;