Expand height range to include -64 to 320

This commit is contained in:
Dylan K. Taylor
2022-04-15 19:10:24 +01:00
parent c1c3475e5a
commit eafbc3a468
5 changed files with 7 additions and 34 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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();