mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Drastically improved performance of basic chunk sky-light population
back 2 commits: 53ms per chunk back 1 commit: 27ms per chunk this commit: 3ms per chunk (on my machine, of course)
This commit is contained in:
@ -30,7 +30,7 @@ class SubChunk implements SubChunkInterface{
|
||||
protected $blockLight;
|
||||
protected $skyLight;
|
||||
|
||||
private static function assignData(&$target, $data, $length, $value = "\x00"){
|
||||
private static function assignData(&$target, string $data, int $length, string $value = "\x00"){
|
||||
if(strlen($data) !== $length){
|
||||
assert($data === "", "Invalid non-zero length given, expected $length, got " . strlen($data));
|
||||
$target = str_repeat($value, $length);
|
||||
@ -203,11 +203,21 @@ class SubChunk implements SubChunkInterface{
|
||||
return $this->skyLight;
|
||||
}
|
||||
|
||||
public function setBlockSkyLightArray(string $data){
|
||||
assert(strlen($data) === 2048, "Wrong length of skylight array, expecting 2048 bytes, got " . strlen($data));
|
||||
$this->skyLight = $data;
|
||||
}
|
||||
|
||||
public function getBlockLightArray() : string{
|
||||
assert(strlen($this->blockLight) === 2048, "Wrong length of light array, expecting 2048 bytes, got " . strlen($this->blockLight));
|
||||
return $this->blockLight;
|
||||
}
|
||||
|
||||
public function setBlockLightArray(string $data){
|
||||
assert(strlen($data) === 2048, "Wrong length of light array, expecting 2048 bytes, got " . strlen($data));
|
||||
$this->blockLight = $data;
|
||||
}
|
||||
|
||||
public function networkSerialize() : string{
|
||||
// storage version, ids, data, skylight, blocklight
|
||||
return "\x00" . $this->ids . $this->data . $this->skyLight . $this->blockLight;
|
||||
|
Reference in New Issue
Block a user