Packet broadcast to players

This commit is contained in:
Shoghi Cervantes Pueyo 2013-05-19 22:49:40 +02:00
parent b9e3acd017
commit 48b5afac46
3 changed files with 19 additions and 9 deletions

View File

@ -440,13 +440,6 @@ class Player{
"eid" => $data->eid,
));
break;
case "time.change":
if($data["level"] === $this->level){
$this->dataPacket(MC_SET_TIME, array(
"time" => $data["time"],
));
}
break;
case "entity.animate":
if($data["eid"] === $this->eid or $data["entity"]->level !== $this->level){
break;
@ -912,7 +905,6 @@ class Player{
$this->entity->z = $this->data->get("position")["z"];
$this->entity->setName($this->username);
$this->entity->data["clientID"] = $this->clientID;
$this->evid[] = $this->server->event("time.change", array($this, "eventHandler"));
$this->evid[] = $this->server->event("server.chat", array($this, "eventHandler"));
$this->evid[] = $this->server->event("entity.remove", array($this, "eventHandler"));
$this->evid[] = $this->server->event("entity.move", array($this, "eventHandler"));

View File

@ -449,6 +449,21 @@ class CustomPacketHandler{
}
}
break;
case MC_LEVEL_EVENT:
if($this->c === false){
$this->data["unknown1"] = Utils::readShort($this->get(2));
$this->data["unknown2"] = Utils::readShort($this->get(2));
$this->data["unknown3"] = Utils::readShort($this->get(2));
$this->data["unknown4"] = Utils::readShort($this->get(2));
$this->data["unknown5"] = Utils::readInt($this->get(4));
}else{
$this->raw .= Utils::writeShort($this->data["unknown1"]);
$this->raw .= Utils::writeShort($this->data["unknown2"]);
$this->raw .= Utils::writeShort($this->data["unknown3"]);
$this->raw .= Utils::writeShort($this->data["unknown4"]);
$this->raw .= Utils::writeInt($this->data["unknown5"]);
}
break;
case MC_ENTITY_EVENT:
if($this->c === false){
$this->data["eid"] = Utils::readInt($this->get(4));

View File

@ -63,14 +63,17 @@ class Level{
}
public function checkThings(){
$players = $this->server->api->player->getAll($this);
$now = microtime(true);
$time = $this->startTime + ($now - $this->startCheck) * 20;
if($this->server->api->dhandle("time.change", array("level" => $this, "time" => $time)) !== false){
$this->time = $time;
$this->server->api->player->broadcastPacket($players, MC_SET_TIME, array(
"time" => $this->time,
));
}
if(count($this->changedCount) > 0){
$players = $this->server->api->player->getAll($this);
arsort($this->changedCount);
$resendChunks = array();
foreach($this->changedCount as $index => $count){