mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Expand height range to include -64 to 320
This commit is contained in:
parent
c1c3475e5a
commit
eafbc3a468
@ -69,7 +69,7 @@ class ChunkRequestTask extends AsyncTask{
|
||||
|
||||
public function onRun() : void{
|
||||
$chunk = FastChunkSerializer::deserializeTerrain($this->chunk);
|
||||
$subCount = ChunkSerializer::getSubChunkCount($chunk) + ChunkSerializer::LOWER_PADDING_SIZE;
|
||||
$subCount = ChunkSerializer::getSubChunkCount($chunk);
|
||||
$encoderContext = new PacketSerializerContext(GlobalItemTypeDictionary::getInstance()->getDictionary());
|
||||
$payload = ChunkSerializer::serializeFullChunk($chunk, RuntimeBlockMapping::getInstance(), $encoderContext, $this->tiles);
|
||||
$this->setResult($this->compressor->compress(PacketBatch::fromPackets($encoderContext, LevelChunkPacket::create($this->chunkX, $this->chunkZ, $subCount, false, null, $payload))->getBuffer()));
|
||||
|
@ -41,8 +41,6 @@ use function count;
|
||||
use function str_repeat;
|
||||
|
||||
final class ChunkSerializer{
|
||||
public const LOWER_PADDING_SIZE = 4;
|
||||
|
||||
private function __construct(){
|
||||
//NOOP
|
||||
}
|
||||
@ -65,12 +63,6 @@ final class ChunkSerializer{
|
||||
public static function serializeFullChunk(Chunk $chunk, RuntimeBlockMapping $blockMapper, PacketSerializerContext $encoderContext, ?string $tiles = null) : string{
|
||||
$stream = PacketSerializer::encoder($encoderContext);
|
||||
|
||||
//TODO: HACK! fill in fake subchunks to make up for the new negative space client-side
|
||||
for($y = 0; $y < self::LOWER_PADDING_SIZE; $y++){
|
||||
$stream->putByte(8); //subchunk version 8
|
||||
$stream->putByte(0); //0 layers - client will treat this as all-air
|
||||
}
|
||||
|
||||
$subChunkCount = self::getSubChunkCount($chunk);
|
||||
for($y = Chunk::MIN_SUBCHUNK_INDEX, $writtenCount = 0; $writtenCount < $subChunkCount; ++$y, ++$writtenCount){
|
||||
self::serializeSubChunk($chunk->getSubChunk($y), $blockMapper, $stream, false);
|
||||
|
@ -134,8 +134,8 @@ class World implements ChunkManager{
|
||||
/** @var int */
|
||||
private static $worldIdCounter = 1;
|
||||
|
||||
public const Y_MAX = 256;
|
||||
public const Y_MIN = 0;
|
||||
public const Y_MAX = 320;
|
||||
public const Y_MIN = -64;
|
||||
|
||||
public const TIME_DAY = 1000;
|
||||
public const TIME_NOON = 6000;
|
||||
|
@ -35,8 +35,8 @@ class Chunk{
|
||||
public const DIRTY_FLAG_BLOCKS = 1 << 0;
|
||||
public const DIRTY_FLAG_BIOMES = 1 << 3;
|
||||
|
||||
public const MIN_SUBCHUNK_INDEX = 0;
|
||||
public const MAX_SUBCHUNK_INDEX = 15;
|
||||
public const MIN_SUBCHUNK_INDEX = -4;
|
||||
public const MAX_SUBCHUNK_INDEX = 19;
|
||||
public const MAX_SUBCHUNKS = self::MAX_SUBCHUNK_INDEX - self::MIN_SUBCHUNK_INDEX + 1;
|
||||
|
||||
public const EDGE_LENGTH = SubChunk::EDGE_LENGTH;
|
||||
|
@ -123,11 +123,11 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
|
||||
}
|
||||
|
||||
public function getWorldMinY() : int{
|
||||
return 0;
|
||||
return -64;
|
||||
}
|
||||
|
||||
public function getWorldMaxY() : int{
|
||||
return 256;
|
||||
return 320;
|
||||
}
|
||||
|
||||
public static function isValid(string $path) : bool{
|
||||
@ -514,25 +514,6 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
|
||||
|
||||
$chunk = $chunkData->getChunk();
|
||||
|
||||
//TODO: This ensures that negative subchunks don't get destroyed in newer worlds for as long as we don't yet
|
||||
//support negative height. Since we don't save with a shift, if the old save had the subchunks shifted, we need
|
||||
//to shift them to their correct positions to avoid destroying data.
|
||||
//This can be removed once we support the full height.
|
||||
if($previousVersion !== null && self::hasOffsetCavesAndCliffsSubChunks($previousVersion)){
|
||||
$subChunks = $chunk->getSubChunks();
|
||||
|
||||
for($y = -4; $y <= 20; $y++){
|
||||
$key = $index . ChunkDataKey::SUBCHUNK . chr($y + self::CAVES_CLIFFS_EXPERIMENTAL_SUBCHUNK_KEY_OFFSET);
|
||||
if(
|
||||
(!isset($subChunks[$y]) || !$chunk->getTerrainDirtyFlag(Chunk::DIRTY_FLAG_BLOCKS)) &&
|
||||
($subChunkData = $this->db->get($key)) !== false
|
||||
){
|
||||
$write->delete($key);
|
||||
$write->put($index . ChunkDataKey::SUBCHUNK . chr($y & 0xff), $subChunkData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($chunk->getTerrainDirtyFlag(Chunk::DIRTY_FLAG_BLOCKS)){
|
||||
$subChunks = $chunk->getSubChunks();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user