diff --git a/src/pocketmine/block/Bed.php b/src/pocketmine/block/Bed.php index b1ee5582c4..dd26f3950b 100644 --- a/src/pocketmine/block/Bed.php +++ b/src/pocketmine/block/Bed.php @@ -145,7 +145,7 @@ class Bed extends Transparent{ return true; } - $time = $this->getWorld()->getTime() % World::TIME_FULL; + $time = $this->getWorld()->getTimeOfDay(); $isNight = ($time >= World::TIME_NIGHT and $time < World::TIME_SUNRISE); diff --git a/src/pocketmine/world/World.php b/src/pocketmine/world/World.php index 6de6ffb3ef..1f83e08ba5 100644 --- a/src/pocketmine/world/World.php +++ b/src/pocketmine/world/World.php @@ -887,7 +887,7 @@ class World implements ChunkManager, Metadatable{ } if($resetTime){ - $time = $this->getTime() % World::TIME_FULL; + $time = $this->getTimeOfDay(); if($time >= World::TIME_NIGHT and $time < World::TIME_SUNRISE){ $this->setTime($this->getTime() + World::TIME_FULL - $time); @@ -2682,6 +2682,15 @@ class World 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 World display name. * WARNING: This is NOT guaranteed to be unique. Multiple worlds at runtime may share the same display name.