diff --git a/src/Player.php b/src/Player.php index 0c9615814..cbc84d375 100644 --- a/src/Player.php +++ b/src/Player.php @@ -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"); diff --git a/src/world/Entity.php b/src/world/Entity.php index d75d0ed1d..67d246132 100644 --- a/src/world/Entity.php +++ b/src/world/Entity.php @@ -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, ));