mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-08-11 05:52:05 +00:00
Update LevelDB to check for layer emptiness instead of null
- Check if layers are empty (bitsPerBlock == 0 and value == emptyBlockId) instead of null when saving subchunks - This aligns with the refactored SubChunk class that now uses non-nullable blockLayer and liquidLayer fields
This commit is contained in:
parent
ba2a7cceaf
commit
30d13508b4
@ -775,19 +775,22 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
|
||||
$subStream = new BinaryStream();
|
||||
$subStream->putByte(self::CURRENT_LEVEL_SUBCHUNK_VERSION);
|
||||
|
||||
$layerCount = 0;
|
||||
$blockLayer = $subChunk->getBlockLayer();
|
||||
$liquidLayer = $subChunk->getLiquidLayer();
|
||||
|
||||
if($blockLayer !== null) $layerCount++;
|
||||
if($liquidLayer !== null) $layerCount++;
|
||||
$isBlockLayerEmpty = $blockLayer->getBitsPerBlock() === 0 && $blockLayer->get(0, 0, 0) === $subChunk->getEmptyBlockId();
|
||||
$isLiquidLayerEmpty = $liquidLayer->getBitsPerBlock() === 0 && $liquidLayer->get(0, 0, 0) === $subChunk->getEmptyBlockId();
|
||||
|
||||
$layerCount = 0;
|
||||
if(!$isBlockLayerEmpty) $layerCount++;
|
||||
if(!$isLiquidLayerEmpty) $layerCount++;
|
||||
|
||||
$subStream->putByte($layerCount);
|
||||
|
||||
if($blockLayer !== null){
|
||||
if(!$isBlockLayerEmpty){
|
||||
$this->serializeBlockPalette($subStream, $blockLayer);
|
||||
}
|
||||
if($liquidLayer !== null){
|
||||
if(!$isLiquidLayerEmpty){
|
||||
$this->serializeBlockPalette($subStream, $liquidLayer);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user