mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 12:09:43 +00:00
sleeping rewritten(+ fix 73)
This commit is contained in:
parent
b969b5d8f1
commit
37b3c02396
3 changed files with 31 additions and 22 deletions
|
|
@ -205,6 +205,21 @@ class Level{
|
|||
|
||||
}
|
||||
|
||||
public function checkSleep(){ //TODO events?
|
||||
if(count($this->players) == 0) return false;
|
||||
if($this->server->api->time->getPhase($this->level) === "night"){ //TODO vanilla
|
||||
foreach($this->players as $p){
|
||||
if($p->isSleeping == false || $p->sleepingTime < 100){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$this->server->api->time->set("day", $this->level);
|
||||
}
|
||||
foreach($this->players as $p){
|
||||
$p->stopSleep();
|
||||
}
|
||||
}
|
||||
|
||||
public function checkThings(){
|
||||
if(!isset($this->level)){
|
||||
return false;
|
||||
|
|
@ -360,6 +375,9 @@ class Level{
|
|||
$e->update();
|
||||
}
|
||||
}
|
||||
|
||||
$this->checkSleep();
|
||||
|
||||
if($server->ticks % 40 === 0){ //40 ticks delay
|
||||
$this->mobSpawner->handle();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue