Level: clean up and remove checkTime()

This commit is contained in:
Dylan K. Taylor 2018-08-06 19:00:00 +01:00
parent fb0cc0804c
commit 4142666df8
2 changed files with 3 additions and 21 deletions

View File

@ -54,9 +54,7 @@ class TimeCommand extends VanillaCommand{
return true;
}
foreach($sender->getServer()->getLevels() as $level){
$level->checkTime();
$level->startTime();
$level->checkTime();
}
Command::broadcastCommandMessage($sender, "Restarted the time");
return true;
@ -67,9 +65,7 @@ class TimeCommand extends VanillaCommand{
return true;
}
foreach($sender->getServer()->getLevels() as $level){
$level->checkTime();
$level->stopTime();
$level->checkTime();
}
Command::broadcastCommandMessage($sender, "Stopped the time");
return true;
@ -109,9 +105,7 @@ class TimeCommand extends VanillaCommand{
}
foreach($sender->getServer()->getLevels() as $level){
$level->checkTime();
$level->setTime($value);
$level->checkTime();
}
Command::broadcastCommandMessage($sender, new TranslationContainer("commands.time.set", [$value]));
}elseif($args[0] === "add"){
@ -123,9 +117,7 @@ class TimeCommand extends VanillaCommand{
$value = $this->getInteger($sender, $args[1], 0);
foreach($sender->getServer()->getLevels() as $level){
$level->checkTime();
$level->setTime($level->getTime() + $value);
$level->checkTime();
}
Command::broadcastCommandMessage($sender, new TranslationContainer("commands.time.added", [$value]));
}else{

View File

@ -653,18 +653,6 @@ class Level implements ChunkManager, Metadatable{
}
}
/**
* WARNING: Do not use this, it's only for internal use.
* Changes to this function won't be recorded on the version.
*/
public function checkTime(){
if($this->stopTime){
return;
}else{
++$this->time;
}
}
/**
* WARNING: Do not use this, it's only for internal use.
* Changes to this function won't be recorded on the version.
@ -696,7 +684,9 @@ class Level implements ChunkManager, Metadatable{
$this->timings->doTick->startTiming();
$this->checkTime();
if(!$this->stopTime){
$this->time++;
}
$this->sunAnglePercentage = $this->computeSunAnglePercentage(); //Sun angle depends on the current time
$this->skyLightReduction = $this->computeSkyLightReduction(); //Sky light reduction depends on the sun angle