Add Level->getTimeOfDay(), closes #2908 (#2979)

This commit is contained in:
Luke 2019-06-22 16:00:18 +01:00 committed by Dylan T
parent 5a17a0d1aa
commit 6afc689529
2 changed files with 11 additions and 2 deletions

View File

@ -146,7 +146,7 @@ class Bed extends Transparent{
return true;
}
$time = $this->getLevel()->getTime() % Level::TIME_FULL;
$time = $this->getLevel()->getTimeOfDay();
$isNight = ($time >= Level::TIME_NIGHT and $time < Level::TIME_SUNRISE);

View File

@ -936,7 +936,7 @@ class Level implements ChunkManager, Metadatable{
}
if($resetTime){
$time = $this->getTime() % Level::TIME_FULL;
$time = $this->getTimeOfDay();
if($time >= Level::TIME_NIGHT and $time < Level::TIME_SUNRISE){
$this->setTime($this->getTime() + Level::TIME_FULL - $time);
@ -3005,6 +3005,15 @@ class Level implements ChunkManager, Metadatable{
return $this->time;
}
/**
* Returns the current time of day
*
* @return int
*/
public function getTimeOfDay() : int{
return $this->time % self::TIME_FULL;
}
/**
* Returns the Level name
*