Some refactoring to allow for light updates to be executed asynchronously

This commit is contained in:
Dylan K. Taylor
2017-06-04 17:49:16 +01:00
parent 0cf3914f5d
commit 8919d4a372
6 changed files with 83 additions and 14 deletions

View File

@ -47,7 +47,7 @@ class SimpleChunkManager implements ChunkManager{
*/
public function getBlockIdAt(int $x, int $y, int $z) : int{
if($chunk = $this->getChunk($x >> 4, $z >> 4)){
return $chunk->getBlockId($x & 0xf, $y & Level::Y_MASK, $z & 0xf);
return $chunk->getBlockId($x & 0xf, $y, $z & 0xf);
}
return 0;
}
@ -62,7 +62,7 @@ class SimpleChunkManager implements ChunkManager{
*/
public function setBlockIdAt(int $x, int $y, int $z, int $id){
if($chunk = $this->getChunk($x >> 4, $z >> 4)){
$chunk->setBlockId($x & 0xf, $y & Level::Y_MASK, $z & 0xf, $id);
$chunk->setBlockId($x & 0xf, $y, $z & 0xf, $id);
}
}
@ -77,7 +77,7 @@ class SimpleChunkManager implements ChunkManager{
*/
public function getBlockDataAt(int $x, int $y, int $z) : int{
if($chunk = $this->getChunk($x >> 4, $z >> 4)){
return $chunk->getBlockData($x & 0xf, $y & Level::Y_MASK, $z & 0xf);
return $chunk->getBlockData($x & 0xf, $y, $z & 0xf);
}
return 0;
}
@ -92,7 +92,35 @@ class SimpleChunkManager implements ChunkManager{
*/
public function setBlockDataAt(int $x, int $y, int $z, int $data){
if($chunk = $this->getChunk($x >> 4, $z >> 4)){
$chunk->setBlockData($x & 0xf, $y & Level::Y_MASK, $z & 0xf, $data);
$chunk->setBlockData($x & 0xf, $y, $z & 0xf, $data);
}
}
public function getBlockLightAt(int $x, int $y, int $z) : int{
if($chunk = $this->getChunk($x >> 4, $z >> 4)){
return $chunk->getBlockLight($x & 0xf, $y, $z & 0xf);
}
return 0;
}
public function setBlockLightAt(int $x, int $y, int $z, int $level){
if($chunk = $this->getChunk($x >> 4, $z >> 4)){
$chunk->setBlockLight($x & 0xf, $y, $z & 0xf, $level);
}
}
public function getBlockSkyLightAt(int $x, int $y, int $z) : int{
if($chunk = $this->getChunk($x >> 4, $z >> 4)){
return $chunk->getBlockSkyLight($x & 0xf, $y, $z & 0xf);
}
return 0;
}
public function setBlockSkyLightAt(int $x, int $y, int $z, int $level){
if($chunk = $this->getChunk($x >> 4, $z >> 4)){
$chunk->setBlockSkyLight($x & 0xf, $y, $z & 0xf, $level);
}
}