mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 04:17:07 +00:00
Level-independient time change
This commit is contained in:
parent
e63677a23d
commit
5ee2cda4a6
@ -28,6 +28,7 @@ the Free Software Foundation, either version 3 of the License, or
|
||||
|
||||
class Deprecation{
|
||||
public static $events = array(
|
||||
"server.time" => "time.change",
|
||||
"world.block.change" => "block.change",
|
||||
"block.drop" => "item.drop",
|
||||
"api.op.check" => "op.check",
|
||||
|
@ -441,10 +441,12 @@ class Player{
|
||||
"eid" => $data->eid,
|
||||
));
|
||||
break;
|
||||
case "server.time":
|
||||
$this->dataPacket(MC_SET_TIME, array(
|
||||
"time" => $data,
|
||||
));
|
||||
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){
|
||||
@ -906,7 +908,7 @@ 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("server.time", array($this, "eventHandler"));
|
||||
$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"));
|
||||
|
@ -27,7 +27,7 @@ the Free Software Foundation, either version 3 of the License, or
|
||||
|
||||
class PocketMinecraftServer{
|
||||
public $tCnt;
|
||||
public $version, $invisible, $api, $tickMeasure, $preparedSQL, $seed, $gamemode, $name, $maxClients, $clients, $eidCnt, $custom, $description, $motd, $timePerSecond;
|
||||
public $version, $invisible, $api, $tickMeasure, $preparedSQL, $seed, $gamemode, $name, $maxClients, $clients, $eidCnt, $custom, $description, $motd;
|
||||
private $port, $serverip, $database, $interface, $evCnt, $handCnt, $events, $eventsID, $handlers, $serverType, $lastTick;
|
||||
|
||||
private function load(){
|
||||
@ -65,8 +65,6 @@ class PocketMinecraftServer{
|
||||
$this->whitelist = false;
|
||||
$this->clients = array();
|
||||
$this->spawn = false;
|
||||
$this->time = 0;
|
||||
$this->timePerSecond = 20;
|
||||
$this->tickMeasure = array_fill(0, 40, 0);
|
||||
$this->setType("normal");
|
||||
$this->interface = new MinecraftInterface("255.255.255.255", $this->port, true, false, $this->serverip);
|
||||
@ -102,7 +100,6 @@ class PocketMinecraftServer{
|
||||
if(ENABLE_ANSI === true){
|
||||
$this->action(1500000, '$this->titleTick();');
|
||||
}
|
||||
$this->action(500000, '$this->time += (int) ($this->timePerSecond / 2);$this->api->dhandle("server.time", $this->time);');
|
||||
$this->action(5000000, 'if($this->difficulty < 2){$this->api->dhandle("server.regeneration", 1);}');
|
||||
$this->action(1000000 * 15, 'if($this->getTPS() < 15){console("[WARNING] Can\'t keep up! Is the server overloaded?");}');
|
||||
$this->action(1000000 * 60 * 10, '$this->custom = array();');
|
||||
|
@ -41,6 +41,14 @@ class Level{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function checkThings(){
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
public function __destruct(){
|
||||
$this->save();
|
||||
unset($this->level);
|
||||
@ -142,11 +150,6 @@ class Level{
|
||||
$this->startCheck = microtime(true);
|
||||
}
|
||||
|
||||
public function checkThings(){
|
||||
$now = microtime(true);
|
||||
$this->time = $this->startTime + ($now - $this->startCheck) * 20;
|
||||
}
|
||||
|
||||
public function getSeed(){
|
||||
return (int) $this->level->getData("seed");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user