Added fixes for hacks like Health protection and speed hack

This commit is contained in:
Shoghi Cervantes Pueyo 2013-04-09 21:02:46 +02:00
parent 2763401be3
commit 076691ec52
2 changed files with 8 additions and 1 deletions

View File

@ -61,6 +61,7 @@ class Player{
private $chunksLoaded = array();
private $chunksOrder = array();
private $lag = array(0, 0);
public $lastCorrect;
function __construct($clientID, $ip, $port, $MTU){
$this->MTU = $MTU;
@ -487,6 +488,7 @@ class Player{
if($pitch === false){
$pitch = $this->entity->yaw;
}
$this->lastCorrect = $pos;
$this->entity->fallY = false;
$this->entity->fallStart = false;
$this->entity->setPosition($pos->x, $pos->y, $pos->z, $yaw, $pitch);
@ -797,7 +799,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, false);
$this->teleport($this->lastCorrect, $this->entity->yaw, $this->entity->pitch, false);
}else{
$this->entity->setPosition($data["x"], $data["y"], $data["z"], $data["yaw"], $data["pitch"]);
}
@ -938,6 +940,7 @@ class Player{
if($this->entity->dead === false){
break;
}
$this->blocked = false;
$this->entity->fire = 0;
$this->entity->air = 300;
$this->entity->setHealth(20, "respawn");

View File

@ -375,6 +375,9 @@ class Entity extends stdClass{
if($this->class === ENTITY_PLAYER){
$this->calculateVelocity();
if($this->getSpeed() <= 0.001){
$this->player->lastCorrect = new Vector3($this->last[0], $this->last[1], $this->last[2]);
}
}
}
@ -644,6 +647,7 @@ class Entity extends stdClass{
$this->server->api->dhandle("entity.event", array("entity" => $this, "event" => 2)); //Ouch! sound
}
if($this->player instanceof Player){
$this->player->blocked = true;
$this->player->dataPacket(MC_SET_HEALTH, array(
"health" => $this->health,
));