More tweaks

This commit is contained in:
Dylan K. Taylor 2016-11-28 18:24:36 +00:00
parent ecabe945e6
commit d70be232d8
3 changed files with 21 additions and 12 deletions

View File

@ -105,4 +105,12 @@ class EmptySubChunk extends SubChunk{
public function getSkyLightArray() : string{
return str_repeat("\xff", 2048);
}
public function networkSerialize() : string{
return "\x00" . str_repeat("\x00", 10240);
}
public function fastSerialize() : string{
return "";
}
}

View File

@ -621,12 +621,7 @@ class GenericChunk implements Chunk{
$subChunkCount = $this->getSubChunkSendCount();
$result .= chr($subChunkCount);
for($y = 0; $y < $subChunkCount; ++$y){
$subChunk = $this->subChunks[$y];
$result .= "\x00" //unknown byte!
. $subChunk->getBlockIdArray()
. $subChunk->getBlockDataArray()
. str_repeat("\x00", 2048) //$subChunk->getSkyLightArray()
. $subChunk->getBlockLightArray();
$result .= $this->subChunks[$y]->networkSerialize();
}
//TODO: heightmaps, tile data
@ -644,11 +639,7 @@ class GenericChunk implements Chunk{
continue;
}
++$count;
$subChunks .= chr($subChunk->getY())
. $subChunk->getBlockIdArray()
. $subChunk->getBlockDataArray()
. $subChunk->getSkyLightArray()
. $subChunk->getBlockLightArray();
$subChunks .= $subChunk->fastSerialize();
}
$stream->putByte($count);
$stream->put($subChunks);
@ -677,7 +668,7 @@ class GenericChunk implements Chunk{
);
}
$heightMap = array_values(unpack("C*", $stream->get(256)));
$biomeColors = array_values(unpack("N*", $stream->get(1024)));
$biomeColors = array_values(unpack("N*", $stream->get(1024))); //TODO: remove this
$chunk = new GenericChunk($provider, $x, $z, $subChunks, $heightMap, $biomeColors);
$flags = $stream->getByte();

View File

@ -202,4 +202,14 @@ class SubChunk{
assert(strlen($this->skyLight) === 2048, "Wrong length of skylight array, expecting 2048 bytes, got " . strlen($this->skyLight));
return $this->skyLight;
}
public function networkSerialize() : string{
// storage version, ids, data, skylight, blocklight
return "\x00" . $this->ids . $this->data . $this->skyLight . $this->blockLight;
}
public function fastSerialize() : string{
// y, ids, data, skylight, blocklight
return chr($this->y) . $this->ids . $this->data . $this->skyLight . $this->blockLight;
}
}