Formatting and doc comments, overall useless commit

This commit is contained in:
Dylan K. Taylor 2016-12-12 14:25:42 +00:00
parent 42b78cfba2
commit 6ea45c5c4a
5 changed files with 30 additions and 21 deletions

View File

@ -328,7 +328,7 @@ interface Chunk{
* @return SubChunk * @return SubChunk
*/ */
public function getSubChunk(int $fY, bool $generateNew = false) : SubChunk; public function getSubChunk(int $fY, bool $generateNew = false) : SubChunk;
/** /**
* @param int $fY 0-15 * @param int $fY 0-15
* @param SubChunk $subChunk * @param SubChunk $subChunk
@ -348,19 +348,19 @@ interface Chunk{
* @return bool * @return bool
*/ */
public function getHighestSubChunkIndex() : int; public function getHighestSubChunkIndex() : int;
/** /**
* Returns the number of subchunks that need sending * Returns the number of subchunks that need sending
* *
* @return int * @return int
*/ */
public function getSubChunkSendCount() : int; public function getSubChunkSendCount() : int;
/** /**
* Disposes of empty subchunks * Disposes of empty subchunks
*/ */
public function pruneEmptySubChunks(); public function pruneEmptySubChunks();
/** /**
* Serializes the chunk to network data * Serializes the chunk to network data
* *

View File

@ -25,7 +25,7 @@ use pocketmine\utils\ChunkException;
class EmptySubChunk extends SubChunk{ class EmptySubChunk extends SubChunk{
protected $y; protected $y;
public function __construct(int $y){ public function __construct(int $y){
$this->y = $y; $this->y = $y;
} }
@ -73,19 +73,19 @@ class EmptySubChunk extends SubChunk{
public function setBlockLight(int $x, int $y, int $z, int $level) : bool{ public function setBlockLight(int $x, int $y, int $z, int $level) : bool{
return false; return false;
} }
public function getBlockIdColumn(int $x, int $z) : string{ public function getBlockIdColumn(int $x, int $z) : string{
return "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; return "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
} }
public function getBlockDataColumn(int $x, int $z) : string{ public function getBlockDataColumn(int $x, int $z) : string{
return "\x00\x00\x00\x00\x00\x00\x00\x00"; return "\x00\x00\x00\x00\x00\x00\x00\x00";
} }
public function getBlockLightColumn(int $x, int $z) : string{ public function getBlockLightColumn(int $x, int $z) : string{
return "\x00\x00\x00\x00\x00\x00\x00\x00"; return "\x00\x00\x00\x00\x00\x00\x00\x00";
} }
public function getSkyLightColumn(int $x, int $z) : string{ public function getSkyLightColumn(int $x, int $z) : string{
return "\xff\xff\xff\xff\xff\xff\xff\xff"; return "\xff\xff\xff\xff\xff\xff\xff\xff";
} }

View File

@ -620,7 +620,8 @@ class GenericChunk implements Chunk{
} }
$result .= pack("v*", ...$this->heightMap) $result .= pack("v*", ...$this->heightMap)
. $this->biomeIds . $this->biomeIds
. chr(0); //border block array count (TODO) . chr(0); //border block array count
//Border block entry format: 1 byte (4 bits X, 4 bits Z). These are however useless since they crash the regular client.
$extraData = new BinaryStream(); $extraData = new BinaryStream();
$extraData->putVarInt(count($this->extraData)); //WHY, Mojang, WHY $extraData->putVarInt(count($this->extraData)); //WHY, Mojang, WHY
@ -695,6 +696,7 @@ class GenericChunk implements Chunk{
return $chunk; return $chunk;
} }
//TODO: get rid of this
public static function getEmptyChunk(int $x, int $z, LevelProvider $provider = null) : Chunk{ public static function getEmptyChunk(int $x, int $z, LevelProvider $provider = null) : Chunk{
return new GenericChunk($provider, $x, $z); return new GenericChunk($provider, $x, $z);
} }
@ -750,6 +752,13 @@ class GenericChunk implements Chunk{
return $result; return $result;
} }
/**
* Converts pre-MCPE-1.0 biome colour array to biome ID array. RIP BiomeColors :(
*
* @param int[256] $array of biome colour values
*
* @return string
*/
public static function convertBiomeColours(array $array) : string{ public static function convertBiomeColours(array $array) : string{
$result = str_repeat("\x00", 256); $result = str_repeat("\x00", 256);
foreach($array as $i => $colour){ foreach($array as $i => $colour){

View File

@ -45,7 +45,7 @@ class SubChunk{
self::assignData($this->blockLight, $blockLight, 2048); self::assignData($this->blockLight, $blockLight, 2048);
self::assignData($this->skyLight, $skyLight, 2048); self::assignData($this->skyLight, $skyLight, 2048);
} }
public function getY() : int{ public function getY() : int{
return $this->y; return $this->y;
} }
@ -168,19 +168,19 @@ class SubChunk{
return -1; //highest block not in this subchunk return -1; //highest block not in this subchunk
} }
public function getBlockIdColumn(int $x, int $z) : string{ public function getBlockIdColumn(int $x, int $z) : string{
return substr($this->ids, (($x << 8) | ($z << 4)), 16); return substr($this->ids, (($x << 8) | ($z << 4)), 16);
} }
public function getBlockDataColumn(int $x, int $z) : string{ public function getBlockDataColumn(int $x, int $z) : string{
return substr($this->data, (($x << 7) | ($z << 3)), 8); return substr($this->data, (($x << 7) | ($z << 3)), 8);
} }
public function getBlockLightColumn(int $x, int $z) : string{ public function getBlockLightColumn(int $x, int $z) : string{
return substr($this->blockLight, (($x << 7) | ($z << 3)), 8); return substr($this->blockLight, (($x << 7) | ($z << 3)), 8);
} }
public function getSkyLightColumn(int $x, int $z) : string{ public function getSkyLightColumn(int $x, int $z) : string{
return substr($this->skyLight, (($x << 7) | ($z << 3)), 8); return substr($this->skyLight, (($x << 7) | ($z << 3)), 8);
} }

View File

@ -35,7 +35,7 @@ use pocketmine\utils\ChunkException;
use pocketmine\utils\MainLogger; use pocketmine\utils\MainLogger;
class McRegion extends BaseLevelProvider{ class McRegion extends BaseLevelProvider{
public static function nbtSerialize(GenericChunk $chunk) : string{ public static function nbtSerialize(GenericChunk $chunk) : string{
$nbt = new CompoundTag("Level", []); $nbt = new CompoundTag("Level", []);
$nbt->xPos = new IntTag("xPos", $chunk->getX()); $nbt->xPos = new IntTag("xPos", $chunk->getX());
@ -62,7 +62,7 @@ class McRegion extends BaseLevelProvider{
} }
} }
} }
$nbt->Blocks = new ByteArrayTag("Blocks", $ids); $nbt->Blocks = new ByteArrayTag("Blocks", $ids);
$nbt->Data = new ByteArrayTag("Data", $data); $nbt->Data = new ByteArrayTag("Data", $data);
$nbt->SkyLight = new ByteArrayTag("SkyLight", $skyLight); $nbt->SkyLight = new ByteArrayTag("SkyLight", $skyLight);
@ -100,7 +100,7 @@ class McRegion extends BaseLevelProvider{
return $writer->writeCompressed(ZLIB_ENCODING_DEFLATE, RegionLoader::$COMPRESSION_LEVEL); return $writer->writeCompressed(ZLIB_ENCODING_DEFLATE, RegionLoader::$COMPRESSION_LEVEL);
} }
public static function nbtDeserialize(string $data, LevelProvider $provider = null){ public static function nbtDeserialize(string $data, LevelProvider $provider = null){
$nbt = new NBT(NBT::BIG_ENDIAN); $nbt = new NBT(NBT::BIG_ENDIAN);
try{ try{
@ -111,9 +111,9 @@ class McRegion extends BaseLevelProvider{
if(!isset($chunk->Level) or !($chunk->Level instanceof CompoundTag)){ if(!isset($chunk->Level) or !($chunk->Level instanceof CompoundTag)){
return null; return null;
} }
$chunk = $chunk->Level; $chunk = $chunk->Level;
$subChunks = []; $subChunks = [];
$fullIds = $chunk->Blocks instanceof ByteArrayTag ? $chunk->Blocks->getValue() : str_repeat("\x00", 32768); $fullIds = $chunk->Blocks instanceof ByteArrayTag ? $chunk->Blocks->getValue() : str_repeat("\x00", 32768);
$fullData = $chunk->Data instanceof ByteArrayTag ? $chunk->Data->getValue() : ($half = str_repeat("\x00", 16384)); $fullData = $chunk->Data instanceof ByteArrayTag ? $chunk->Data->getValue() : ($half = str_repeat("\x00", 16384));
@ -155,7 +155,7 @@ class McRegion extends BaseLevelProvider{
}else{ }else{
$biomeIds = ""; $biomeIds = "";
} }
$result = new GenericChunk( $result = new GenericChunk(
$provider, $provider,
$chunk["xPos"], $chunk["xPos"],