diff --git a/src/network/CustomPacketHandler.php b/src/network/CustomPacketHandler.php index c23bc7e4c..b56d97759 100644 --- a/src/network/CustomPacketHandler.php +++ b/src/network/CustomPacketHandler.php @@ -193,8 +193,10 @@ class CustomPacketHandler{ case MC_SET_TIME: if($this->c === false){ $this->data["time"] = Utils::readInt($this->get(4)); + $this->data["started"] = ord($this->get(1)) & 0x80 > 0; }else{ $this->raw .= Utils::writeInt($this->data["time"])."\x80"; + $this->raw .= chr((isset($this->data["started"]) and $this->data["started"] == true) ? 0x80:0x00); } break; case MC_START_GAME: diff --git a/src/world/Level.php b/src/world/Level.php index 3e62e02db..07acd3835 100644 --- a/src/world/Level.php +++ b/src/world/Level.php @@ -21,7 +21,7 @@ class Level{ public $entities, $tiles, $blockUpdates, $nextSave, $players = array(), $level; - private $time, $startCheck, $startTime, $server, $name, $usedChunks, $changedBlocks, $changedCount; + private $time, $startCheck, $startTime, $server, $name, $usedChunks, $changedBlocks, $changedCount, $stopTime; public function __construct(PMFLevel $level, Config $entities, Config $tiles, Config $blockUpdates, $name){ $this->server = ServerAPI::request(); @@ -33,6 +33,7 @@ class Level{ $this->startTime = $this->time = (int) $this->level->getData("time"); $this->nextSave = $this->startCheck = microtime(true); $this->nextSave += 90; + $this->stopTime = false; $this->server->schedule(15, array($this, "checkThings"), array(), true); $this->server->schedule(20 * 13, array($this, "checkTime"), array(), true); $this->name = $name; @@ -70,11 +71,16 @@ class Level{ return false; } $now = microtime(true); - $time = $this->startTime + ($now - $this->startCheck) * 20; + if($this->stopTime == true){ + + }else{ + $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($this->players, MC_SET_TIME, array( "time" => (int) $this->time, + "started" => $this->stopTime == false, )); } } @@ -470,6 +476,18 @@ class Level{ $this->checkTime(); } + public function stopTime(){ + $this->stopTime = true; + $this->startCheck = 0; + $this->checkTime(); + } + + public function startTime(){ + $this->stopTime = false; + $this->startCheck = microtime(true); + $this->checkTime(); + } + public function getSeed(){ if(!isset($this->level)){ return false;