Removed masks for Y coordinates, fixed bugs related to out-of-bounds coordinates, fixed #914 (#915)

This commit is contained in:
Dylan K. Taylor
2017-06-21 10:55:38 +01:00
committed by GitHub
parent 69ae37d191
commit 0f79b19fdc
6 changed files with 105 additions and 36 deletions

View File

@ -62,9 +62,14 @@ abstract class LightUpdate{
abstract protected function setLight(int $x, int $y, int $z, int $level);
public function setAndUpdateLight(int $x, int $y, int $z, int $newLevel){
if(!$this->level->isInWorld($x, $y, $z)){
throw new \InvalidArgumentException("Coordinates x=$x, y=$y, z=$z are out of range");
}
if(isset($this->spreadVisited[$index = Level::blockHash($x, $y, $z)]) or isset($this->removalVisited[$index])){
throw new \InvalidArgumentException("Already have a visit ready for this block");
}
$oldLevel = $this->getLight($x, $y, $z);
if($oldLevel !== $newLevel){
@ -93,7 +98,7 @@ abstract class LightUpdate{
];
foreach($points as list($cx, $cy, $cz)){
if($cy < 0){
if(!$this->level->isInWorld($cx, $cy, $cz)){
continue;
}
$this->computeRemoveLight($cx, $cy, $cz, $oldAdjacentLight);
@ -118,7 +123,7 @@ abstract class LightUpdate{
];
foreach($points as list($cx, $cy, $cz)){
if($cy < 0){
if(!$this->level->isInWorld($cx, $cy, $cz)){
continue;
}
$this->computeSpreadLight($cx, $cy, $cz, $newAdjacentLight);