mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 10:53:05 +00:00
Protocol changes
This commit is contained in:
@ -62,10 +62,6 @@ class Chunk extends BaseChunk{
|
||||
$this->nbt->Sections->setTagType(NBT::TAG_Compound);
|
||||
}
|
||||
|
||||
if(!isset($this->nbt->Biomes) or !($this->nbt->Biomes instanceof ByteArray)){
|
||||
$this->nbt->Biomes = new ByteArray("Biomes", str_repeat("\x01", 256));
|
||||
}
|
||||
|
||||
if(!isset($this->nbt->BiomeColors) or !($this->nbt->BiomeColors instanceof IntArray)){
|
||||
$this->nbt->BiomeColors = new IntArray("BiomeColors", array_fill(0, 256, Binary::readInt("\x00\x85\xb2\x4a")));
|
||||
}
|
||||
@ -89,7 +85,7 @@ class Chunk extends BaseChunk{
|
||||
}
|
||||
}
|
||||
|
||||
parent::__construct($level, (int) $this->nbt["xPos"], (int) $this->nbt["zPos"], $sections, $this->nbt->Biomes->getValue(), $this->nbt->BiomeColors->getValue(), $this->nbt->HeightMap->getValue(), $this->nbt->Entities->getValue(), $this->nbt->TileEntities->getValue());
|
||||
parent::__construct($level, (int) $this->nbt["xPos"], (int) $this->nbt["zPos"], $sections, $this->nbt->BiomeColors->getValue(), $this->nbt->HeightMap->getValue(), $this->nbt->Entities->getValue(), $this->nbt->TileEntities->getValue());
|
||||
|
||||
unset($this->nbt->Sections);
|
||||
}
|
||||
@ -196,7 +192,6 @@ class Chunk extends BaseChunk{
|
||||
]);
|
||||
}
|
||||
|
||||
$nbt->Biomes = new ByteArray("Biomes", $this->getBiomeIdArray());
|
||||
$nbt->BiomeColors = new IntArray("BiomeColors", $this->getBiomeColorArray());
|
||||
|
||||
$nbt->HeightMap = new IntArray("HeightMap", $this->getHeightMapArray());
|
||||
@ -250,7 +245,6 @@ class Chunk extends BaseChunk{
|
||||
]);
|
||||
}
|
||||
|
||||
$nbt->Biomes = new ByteArray("Biomes", $this->getBiomeIdArray());
|
||||
$nbt->BiomeColors = new IntArray("BiomeColors", $this->getBiomeColorArray());
|
||||
|
||||
$nbt->HeightMap = new IntArray("HeightMap", $this->getHeightMapArray());
|
||||
|
@ -38,7 +38,6 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{
|
||||
* @param int $x
|
||||
* @param int $z
|
||||
* @param ChunkSection[] $sections
|
||||
* @param string $biomeIds
|
||||
* @param int[] $biomeColors
|
||||
* @param int[] $heightMap
|
||||
* @param Compound[] $entities
|
||||
@ -46,7 +45,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{
|
||||
*
|
||||
* @throws ChunkException
|
||||
*/
|
||||
protected function __construct($provider, $x, $z, array $sections, $biomeIds = null, array $biomeColors = [], array $heightMap = [], array $entities = [], array $tiles = []){
|
||||
protected function __construct($provider, $x, $z, array $sections, array $biomeColors = [], array $heightMap = [], array $entities = [], array $tiles = []){
|
||||
$this->provider = $provider;
|
||||
$this->x = (int) $x;
|
||||
$this->z = (int) $z;
|
||||
@ -65,17 +64,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{
|
||||
if(count($biomeColors) === 256){
|
||||
$this->biomeColors = $biomeColors;
|
||||
}else{
|
||||
$this->biomeColors = array_fill(0, 256, Binary::readInt("\x00\x85\xb2\x4a"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(strlen($biomeIds) !== 256){
|
||||
$biomeIds = str_repeat("\x01", 256);
|
||||
}
|
||||
|
||||
for($i = 0; $i < 256; ++$i){
|
||||
$this->biomeColors[$i] = ($this->biomeColors[$i] & 0xFFFFFF) | (ord($biomeIds{$i}) << 24);
|
||||
$this->biomeColors = array_fill(0, 256, Binary::readInt("\x01\x85\xb2\x4a"));
|
||||
}
|
||||
|
||||
if(count($heightMap) === 256){
|
||||
|
@ -73,13 +73,12 @@ abstract class BaseFullChunk implements FullChunk{
|
||||
* @param string $data
|
||||
* @param string $skyLight
|
||||
* @param string $blockLight
|
||||
* @param string $biomeIds
|
||||
* @param int[] $biomeColors
|
||||
* @param int[] $heightMap
|
||||
* @param Compound[] $entities
|
||||
* @param Compound[] $tiles
|
||||
*/
|
||||
protected function __construct($provider, $x, $z, $blocks, $data, $skyLight, $blockLight, $biomeIds = null, array $biomeColors = [], array $heightMap = [], array $entities = [], array $tiles = []){
|
||||
protected function __construct($provider, $x, $z, $blocks, $data, $skyLight, $blockLight, array $biomeColors = [], array $heightMap = [], array $entities = [], array $tiles = []){
|
||||
$this->provider = $provider;
|
||||
$this->x = (int) $x;
|
||||
$this->z = (int) $z;
|
||||
@ -92,15 +91,7 @@ abstract class BaseFullChunk implements FullChunk{
|
||||
if(count($biomeColors) === 256){
|
||||
$this->biomeColors = $biomeColors;
|
||||
}else{
|
||||
$this->biomeColors = array_fill(0, 256, Binary::readInt("\x00\x85\xb2\x4a"));
|
||||
}
|
||||
|
||||
if(strlen($biomeIds) !== 256){
|
||||
$biomeIds = str_repeat("\x01", 256);
|
||||
}
|
||||
|
||||
for($i = 0; $i < 256; ++$i){
|
||||
$this->biomeColors[$i] = ($this->biomeColors[$i] & 0xFFFFFF) | (ord($biomeIds{$i}) << 24);
|
||||
$this->biomeColors = array_fill(0, 256, Binary::readInt("\x01\x85\xb2\x4a"));
|
||||
}
|
||||
|
||||
if(count($heightMap) === 256){
|
||||
|
@ -33,8 +33,6 @@ class Chunk extends BaseFullChunk{
|
||||
protected $isGenerated = false;
|
||||
|
||||
public function __construct($level, $chunkX, $chunkZ, $terrain, array $entityData = null, array $tileData = null){
|
||||
$heightMap = array_fill(0, 256, 127);
|
||||
|
||||
$offset = 0;
|
||||
|
||||
$blocks = substr($terrain, $offset, 32768);
|
||||
@ -45,7 +43,11 @@ class Chunk extends BaseFullChunk{
|
||||
$offset += 16384;
|
||||
$blockLight = substr($terrain, $offset, 16384);
|
||||
$offset += 16384;
|
||||
$biomes = substr($terrain, $offset, 256);
|
||||
|
||||
$heightMap = [];
|
||||
foreach(unpack("C*", substr($terrain, $offset, 256)) as $c){
|
||||
$heightMap[] = $c;
|
||||
}
|
||||
$offset += 256;
|
||||
|
||||
$biomeColors = [];
|
||||
@ -54,7 +56,7 @@ class Chunk extends BaseFullChunk{
|
||||
}
|
||||
$offset += 1024;
|
||||
|
||||
parent::__construct($level, $chunkX, $chunkZ, $blocks, $data, $skyLight, $blockLight, $biomes, $biomeColors, $heightMap, $entityData === null ? [] : $entityData, $tileData === null ? [] : $tileData);
|
||||
parent::__construct($level, $chunkX, $chunkZ, $blocks, $data, $skyLight, $blockLight, $biomeColors, $heightMap, $entityData === null ? [] : $entityData, $tileData === null ? [] : $tileData);
|
||||
}
|
||||
|
||||
public function getBlockId($x, $y, $z){
|
||||
@ -321,6 +323,7 @@ class Chunk extends BaseFullChunk{
|
||||
|
||||
}
|
||||
|
||||
$heighmap = pack("C*", ...$this->getHeightMapArray());
|
||||
$biomeColors = pack("N*", ...$this->getBiomeColorArray());
|
||||
|
||||
return $chunkIndex .
|
||||
@ -328,7 +331,7 @@ class Chunk extends BaseFullChunk{
|
||||
$this->getBlockDataArray() .
|
||||
$this->getBlockSkyLightArray() .
|
||||
$this->getBlockLightArray() .
|
||||
$this->getBiomeIdArray() .
|
||||
$heighmap .
|
||||
$biomeColors . chr(
|
||||
($this->isPopulated() ? 0x02 : 0) | ($this->isGenerated() ? 0x01 : 0)
|
||||
);
|
||||
|
@ -67,12 +67,8 @@ class Chunk extends BaseFullChunk{
|
||||
$this->nbt->TileTicks->setTagType(NBT::TAG_Compound);
|
||||
}
|
||||
|
||||
if(!isset($this->nbt->Biomes) or !($this->nbt->Biomes instanceof ByteArray)){
|
||||
$this->nbt->Biomes = new ByteArray("Biomes", str_repeat("\x01", 256));
|
||||
}
|
||||
|
||||
if(!isset($this->nbt->BiomeColors) or !($this->nbt->BiomeColors instanceof IntArray)){
|
||||
$this->nbt->BiomeColors = new IntArray("BiomeColors", array_fill(0, 256, Binary::readInt("\x00\x85\xb2\x4a")));
|
||||
$this->nbt->BiomeColors = new IntArray("BiomeColors", array_fill(0, 256, Binary::readInt("\x01\x85\xb2\x4a")));
|
||||
}
|
||||
|
||||
if(!isset($this->nbt->HeightMap) or !($this->nbt->HeightMap instanceof IntArray)){
|
||||
@ -89,7 +85,7 @@ class Chunk extends BaseFullChunk{
|
||||
$this->nbt->BlockLight = new ByteArray("BlockLight", $half);
|
||||
}
|
||||
|
||||
parent::__construct($level, $this->nbt["xPos"], $this->nbt["zPos"], $this->nbt->Blocks->getValue(), $this->nbt->Data->getValue(), $this->nbt->SkyLight->getValue(), $this->nbt->BlockLight->getValue(), $this->nbt->Biomes->getValue(), $this->nbt->BiomeColors->getValue(), $this->nbt->HeightMap->getValue(), $this->nbt->Entities->getValue(), $this->nbt->TileEntities->getValue());
|
||||
parent::__construct($level, $this->nbt["xPos"], $this->nbt["zPos"], $this->nbt->Blocks->getValue(), $this->nbt->Data->getValue(), $this->nbt->SkyLight->getValue(), $this->nbt->BlockLight->getValue(), $this->nbt->BiomeColors->getValue(), $this->nbt->HeightMap->getValue(), $this->nbt->Entities->getValue(), $this->nbt->TileEntities->getValue());
|
||||
unset($this->nbt->Blocks);
|
||||
unset($this->nbt->Data);
|
||||
unset($this->nbt->SkyLight);
|
||||
@ -314,15 +310,12 @@ class Chunk extends BaseFullChunk{
|
||||
$chunk->blockLight = substr($data, $offset, 16384);
|
||||
$offset += 16384;
|
||||
|
||||
$chunk->biomeIds = substr($data, $offset, 256);
|
||||
$offset += 256;
|
||||
|
||||
$chunk->biomeColors = [];
|
||||
$chunk->heightMap = [];
|
||||
$chunk->biomeColors = [];
|
||||
$hm = unpack("C*", substr($data, $offset, 256));
|
||||
$offset += 256;
|
||||
$bc = unpack("N*", substr($data, $offset, 1024));
|
||||
$offset += 1024;
|
||||
$hm = unpack("N*", substr($data, $offset, 1024));
|
||||
$offset += 1024;
|
||||
|
||||
for($i = 0; $i < 256; ++$i){
|
||||
$chunk->biomeColors[$i] = $bc[$i + 1];
|
||||
@ -341,8 +334,8 @@ class Chunk extends BaseFullChunk{
|
||||
}
|
||||
|
||||
public function toFastBinary(){
|
||||
$heightMap = pack("C*", ...$this->getHeightMapArray());
|
||||
$biomeColors = pack("N*", ...$this->getBiomeColorArray());
|
||||
$heightMap = pack("N*", ...$this->getHeightMapArray());
|
||||
|
||||
return
|
||||
Binary::writeInt($this->x) .
|
||||
@ -351,9 +344,8 @@ class Chunk extends BaseFullChunk{
|
||||
$this->getBlockDataArray() .
|
||||
$this->getBlockSkyLightArray() .
|
||||
$this->getBlockLightArray() .
|
||||
$this->getBiomeIdArray() .
|
||||
$biomeColors .
|
||||
$heightMap .
|
||||
$biomeColors .
|
||||
chr(($this->isPopulated() ? 1 << 1 : 0) + ($this->isGenerated() ? 1 : 0));
|
||||
}
|
||||
|
||||
@ -369,7 +361,6 @@ class Chunk extends BaseFullChunk{
|
||||
$nbt->SkyLight = new ByteArray("SkyLight", $this->getBlockSkyLightArray());
|
||||
$nbt->BlockLight = new ByteArray("BlockLight", $this->getBlockLightArray());
|
||||
|
||||
$nbt->Biomes = new ByteArray("Biomes", $this->getBiomeIdArray());
|
||||
$nbt->BiomeColors = new IntArray("BiomeColors", $this->getBiomeColorArray());
|
||||
|
||||
$nbt->HeightMap = new IntArray("HeightMap", $this->getHeightMapArray());
|
||||
|
Reference in New Issue
Block a user