mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 00:07:30 +00:00
Fix lighting population, fix lighting issues when read by vanilla Minecraft
This commit is contained in:
parent
085d1a1359
commit
946d301bc7
@ -437,21 +437,22 @@ class Chunk{
|
||||
for($z = 0; $z < 16; ++$z){
|
||||
$heightMap = $this->getHeightMap($x, $z);
|
||||
|
||||
$y = min(($this->getHighestSubChunkIndex() + 1) << 4, $heightMap);
|
||||
$y = ($this->getHighestSubChunkIndex() + 1) << 4;
|
||||
|
||||
//TODO: replace a section of the array with a string in one call to improve performance
|
||||
|
||||
for(; $y > $heightMap; --$y){
|
||||
$this->setBlockSkyLight($x, $y, $z, 15);
|
||||
}
|
||||
|
||||
for(; $y > 0; --$y){
|
||||
if($this->getBlockId($x, $y, $z) !== Block::AIR){
|
||||
break;
|
||||
}
|
||||
|
||||
for(; $y > 0 and $this->getBlockId($x, $y, $z) === Block::AIR; --$y){
|
||||
$this->setBlockSkyLight($x, $y, $z, 15);
|
||||
}
|
||||
|
||||
$this->setHeightMap($x, $z, $y);
|
||||
|
||||
for(; $y > 0; --$y){
|
||||
$this->setBlockSkyLight($x, $y, $z, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,10 +30,10 @@ class SubChunk{
|
||||
protected $blockLight;
|
||||
protected $skyLight;
|
||||
|
||||
private static function assignData(&$target, $data, $length){
|
||||
private static function assignData(&$target, $data, $length, $value = "\x00"){
|
||||
if(strlen($data) !== $length){
|
||||
assert($data === "", "Invalid non-zero length given, expected $length, got " . strlen($data));
|
||||
$target = str_repeat("\x00", $length);
|
||||
$target = str_repeat($value, $length);
|
||||
}else{
|
||||
$target = $data;
|
||||
}
|
||||
@ -42,7 +42,7 @@ class SubChunk{
|
||||
public function __construct(string $ids = "", string $data = "", string $skyLight = "", string $blockLight = ""){
|
||||
self::assignData($this->ids, $ids, 4096);
|
||||
self::assignData($this->data, $data, 2048);
|
||||
self::assignData($this->skyLight, $skyLight, 2048);
|
||||
self::assignData($this->skyLight, $skyLight, 2048, "\xff");
|
||||
self::assignData($this->blockLight, $blockLight, 2048);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user