SubChunk: get rid of dead light getters and setters

these were here for fast access, but that fast access path now goes through getBlock(Sky)LightArray() instead.
This commit is contained in:
Dylan K. Taylor 2019-07-09 13:43:01 +01:00
parent c1212eab8e
commit 4264923f4f
4 changed files with 4 additions and 78 deletions

View File

@ -202,7 +202,7 @@ class Chunk{
* @return int 0-15
*/
public function getBlockSkyLight(int $x, int $y, int $z) : int{
return $this->getSubChunk($y >> 4)->getBlockSkyLight($x, $y & 0x0f, $z);
return $this->getSubChunk($y >> 4)->getBlockSkyLightArray()->get($x & 0xf, $y & 0x0f, $z & 0xf);
}
/**
@ -214,7 +214,7 @@ class Chunk{
* @param int $level 0-15
*/
public function setBlockSkyLight(int $x, int $y, int $z, int $level) : void{
$this->getSubChunk($y >> 4, true)->setBlockSkyLight($x, $y & 0x0f, $z, $level);
$this->getSubChunk($y >> 4, true)->getBlockSkyLightArray()->set($x & 0xf, $y & 0x0f, $z & 0xf, $level);
}
/**
@ -238,7 +238,7 @@ class Chunk{
* @return int 0-15
*/
public function getBlockLight(int $x, int $y, int $z) : int{
return $this->getSubChunk($y >> 4)->getBlockLight($x, $y & 0x0f, $z);
return $this->getSubChunk($y >> 4)->getBlockLightArray()->get($x & 0xf, $y & 0x0f, $z & 0xf);
}
/**
@ -250,7 +250,7 @@ class Chunk{
* @param int $level 0-15
*/
public function setBlockLight(int $x, int $y, int $z, int $level) : void{
$this->getSubChunk($y >> 4, true)->setBlockLight($x, $y & 0x0f, $z, $level);
$this->getSubChunk($y >> 4, true)->getBlockLightArray()->set($x & 0xf, $y & 0x0f, $z & 0xf, $level);
}
/**

View File

@ -51,22 +51,6 @@ class EmptySubChunk implements SubChunkInterface{
return [];
}
public function getBlockLight(int $x, int $y, int $z) : int{
return 0;
}
public function setBlockLight(int $x, int $y, int $z, int $level) : bool{
return false;
}
public function getBlockSkyLight(int $x, int $y, int $z) : int{
return 15;
}
public function setBlockSkyLight(int $x, int $y, int $z, int $level) : bool{
return false;
}
public function getHighestBlockAt(int $x, int $z) : int{
return -1;
}

View File

@ -90,26 +90,6 @@ class SubChunk implements SubChunkInterface{
return $this->blockLayers;
}
public function getBlockLight(int $x, int $y, int $z) : int{
return $this->blockLight->get($x, $y, $z);
}
public function setBlockLight(int $x, int $y, int $z, int $level) : bool{
$this->blockLight->set($x, $y, $z, $level);
return true;
}
public function getBlockSkyLight(int $x, int $y, int $z) : int{
return $this->skyLight->get($x, $y, $z);
}
public function setBlockSkyLight(int $x, int $y, int $z, int $level) : bool{
$this->skyLight->set($x, $y, $z, $level);
return true;
}
public function getHighestBlockAt(int $x, int $z) : int{
if(empty($this->blockLayers)){
return -1;

View File

@ -54,44 +54,6 @@ interface SubChunkInterface{
*/
public function getBlockLayers() : array;
/**
* @param int $x
* @param int $y
* @param int $z
*
* @return int
*/
public function getBlockLight(int $x, int $y, int $z) : int;
/**
* @param int $x
* @param int $y
* @param int $z
* @param int $level
*
* @return bool
*/
public function setBlockLight(int $x, int $y, int $z, int $level) : bool;
/**
* @param int $x
* @param int $y
* @param int $z
*
* @return int
*/
public function getBlockSkyLight(int $x, int $y, int $z) : int;
/**
* @param int $x
* @param int $y
* @param int $z
* @param int $level
*
* @return bool
*/
public function setBlockSkyLight(int $x, int $y, int $z, int $level) : bool;
/**
* @param int $x
* @param int $z