Fixed #767 Players move laggy [gh#767]

This commit is contained in:
Shoghi Cervantes 2013-09-04 19:33:11 +02:00
parent 7f15b27ff0
commit 56d829eec6
2 changed files with 15 additions and 5 deletions

View File

@ -632,7 +632,7 @@ class Player{
if($m !== ""){ if($m !== ""){
$this->dataPacket(MC_CHAT, array( $this->dataPacket(MC_CHAT, array(
"player" => ($author instanceof Player) ? $author->username:$author, "player" => ($author instanceof Player) ? $author->username:$author,
"message" => $m, "message" => TextFormat::clean($m), //Colors not implemented :(
)); ));
} }
} }
@ -1284,6 +1284,7 @@ class Player{
$this->server->api->entity->spawnToAll($this->entity); $this->server->api->entity->spawnToAll($this->entity);
$this->server->schedule(5, array($this->entity, "update"), array(), true); $this->server->schedule(5, array($this->entity, "update"), array(), true);
$this->server->schedule(2, array($this->entity, "checkMovement"), array(), true);
$this->sendArmor(); $this->sendArmor();
$this->sendChat($this->server->motd."\n"); $this->sendChat($this->server->motd."\n");

View File

@ -507,6 +507,19 @@ class Entity extends Position{
} }
} }
$this->lastUpdate = $now;
if($this->class !== ENTITY_PLAYER){
$this->updateMovement();
if($hasUpdate === true){
$this->server->schedule(5, array($this, "update"));
}
}
}
public function updateMovement(){
if($this->closed === true){
return false;
}
if($this->isStatic === false and ($this->last[0] != $this->x or $this->last[1] != $this->y or $this->last[2] != $this->z or $this->last[3] != $this->yaw or $this->last[4] != $this->pitch)){ if($this->isStatic === false and ($this->last[0] != $this->x or $this->last[1] != $this->y or $this->last[2] != $this->z or $this->last[3] != $this->yaw or $this->last[4] != $this->pitch)){
if($this->class === ENTITY_PLAYER or ($this->last[5] + 8) < $now){ if($this->class === ENTITY_PLAYER or ($this->last[5] + 8) < $now){
if($this->server->api->handle("entity.move", $this) === false){ if($this->server->api->handle("entity.move", $this) === false){
@ -534,10 +547,6 @@ class Entity extends Position{
$this->updatePosition($this->x, $this->y, $this->z, $this->yaw, $this->pitch); $this->updatePosition($this->x, $this->y, $this->z, $this->yaw, $this->pitch);
} }
} }
$this->lastUpdate = $now;
if($this->class !== ENTITY_PLAYER and $hasUpdate === true){
$this->server->schedule(5, array($this, "update"));
}
} }
public function getDirection(){ public function getDirection(){