phpdoc armageddon for master, pass 1

This commit is contained in:
Dylan K. Taylor
2020-01-22 11:55:03 +00:00
parent 4bae3baa74
commit 67bcc1c0fb
397 changed files with 0 additions and 5391 deletions

View File

@@ -90,12 +90,9 @@ class Chunk{
protected $NBTentities;
/**
* @param int $chunkX
* @param int $chunkZ
* @param SubChunk[] $subChunks
* @param CompoundTag[] $entities
* @param CompoundTag[] $tiles
* @param string $biomeIds
* @param int[] $heightMap
*/
public function __construct(int $chunkX, int $chunkZ, array $subChunks = [], ?array $entities = null, ?array $tiles = null, string $biomeIds = "", array $heightMap = []){
@@ -127,16 +124,10 @@ class Chunk{
$this->NBTentities = $entities;
}
/**
* @return int
*/
public function getX() : int{
return $this->x;
}
/**
* @return int
*/
public function getZ() : int{
return $this->z;
}
@@ -145,17 +136,12 @@ class Chunk{
$this->x = $x;
}
/**
* @param int $z
*/
public function setZ(int $z) : void{
$this->z = $z;
}
/**
* Returns the chunk height in count of subchunks.
*
* @return int
*/
public function getHeight() : int{
return $this->subChunks->getSize();
@@ -176,11 +162,6 @@ class Chunk{
/**
* Sets the blockstate at the given coordinate by internal ID.
*
* @param int $x
* @param int $y
* @param int $z
* @param int $block
*/
public function setFullBlock(int $x, int $y, int $z, int $block) : void{
$this->getSubChunk($y >> 4)->setFullBlock($x, $y & 0xf, $z, $block);
@@ -212,9 +193,6 @@ class Chunk{
$this->getSubChunk($y >> 4)->getBlockSkyLightArray()->set($x & 0xf, $y & 0x0f, $z & 0xf, $level);
}
/**
* @param int $level
*/
public function setAllBlockSkyLight(int $level) : void{
for($y = $this->subChunks->count() - 1; $y >= 0; --$y){
$this->getSubChunk($y)->setBlockSkyLightArray(LightArray::fill($level));
@@ -246,9 +224,6 @@ class Chunk{
$this->getSubChunk($y >> 4)->getBlockLightArray()->set($x & 0xf, $y & 0x0f, $z & 0xf, $level);
}
/**
* @param int $level
*/
public function setAllBlockLight(int $level) : void{
for($y = $this->subChunks->count() - 1; $y >= 0; --$y){
$this->getSubChunk($y)->setBlockLightArray(LightArray::fill($level));
@@ -279,8 +254,6 @@ class Chunk{
*
* @param int $x 0-15
* @param int $z 0-15
*
* @return int
*/
public function getHeightMap(int $x, int $z) : int{
return $this->heightMap[($z << 4) | $x];
@@ -291,7 +264,6 @@ class Chunk{
*
* @param int $x 0-15
* @param int $z 0-15
* @param int $value
*/
public function setHeightMap(int $x, int $z, int $value) : void{
$this->heightMap[($z << 4) | $x] = $value;
@@ -384,51 +356,30 @@ class Chunk{
$this->dirtyFlags |= self::DIRTY_FLAG_BIOMES;
}
/**
* @return bool
*/
public function isLightPopulated() : bool{
return $this->lightPopulated;
}
/**
* @param bool $value
*/
public function setLightPopulated(bool $value = true) : void{
$this->lightPopulated = $value;
}
/**
* @return bool
*/
public function isPopulated() : bool{
return $this->terrainPopulated;
}
/**
* @param bool $value
*/
public function setPopulated(bool $value = true) : void{
$this->terrainPopulated = $value;
}
/**
* @return bool
*/
public function isGenerated() : bool{
return $this->terrainGenerated;
}
/**
* @param bool $value
*/
public function setGenerated(bool $value = true) : void{
$this->terrainGenerated = $value;
}
/**
* @param Entity $entity
*/
public function addEntity(Entity $entity) : void{
if($entity->isClosed()){
throw new \InvalidArgumentException("Attempted to add a garbage closed Entity to a chunk");
@@ -439,9 +390,6 @@ class Chunk{
}
}
/**
* @param Entity $entity
*/
public function removeEntity(Entity $entity) : void{
unset($this->entities[$entity->getId()]);
if(!($entity instanceof Player)){
@@ -449,9 +397,6 @@ class Chunk{
}
}
/**
* @param Tile $tile
*/
public function addTile(Tile $tile) : void{
if($tile->isClosed()){
throw new \InvalidArgumentException("Attempted to add a garbage closed Tile to a chunk");
@@ -465,9 +410,6 @@ class Chunk{
$this->dirtyFlags |= self::DIRTY_FLAG_TILES;
}
/**
* @param Tile $tile
*/
public function removeTile(Tile $tile) : void{
$pos = $tile->getPos();
unset($this->tiles[Chunk::blockHash($pos->x, $pos->y, $pos->z)]);
@@ -503,8 +445,6 @@ class Chunk{
* @param int $x 0-15
* @param int $y
* @param int $z 0-15
*
* @return Tile|null
*/
public function getTile(int $x, int $y, int $z) : ?Tile{
return $this->tiles[Chunk::blockHash($x, $y, $z)] ?? null;
@@ -542,8 +482,6 @@ class Chunk{
/**
* Deserializes tiles and entities from NBT
*
* @param World $world
*/
public function initChunk(World $world) : void{
if($this->NBTentities !== null){
@@ -586,9 +524,6 @@ class Chunk{
}
}
/**
* @return string
*/
public function getBiomeIdArray() : string{
return $this->biomeIds;
}
@@ -611,9 +546,6 @@ class Chunk{
$this->heightMap = \SplFixedArray::fromArray($values);
}
/**
* @return bool
*/
public function isDirty() : bool{
return $this->dirtyFlags !== 0 or !empty($this->tiles) or !empty($this->getSavableEntities());
}
@@ -622,9 +554,6 @@ class Chunk{
return ($this->dirtyFlags & $flag) !== 0;
}
/**
* @return int
*/
public function getDirtyFlags() : int{
return $this->dirtyFlags;
}
@@ -647,10 +576,6 @@ class Chunk{
/**
* Returns the subchunk at the specified subchunk Y coordinate, or an empty, unmodifiable stub if it does not exist or the coordinate is out of range.
*
* @param int $y
*
* @return SubChunkInterface
*/
public function getSubChunk(int $y) : SubChunkInterface{
if($y < 0 or $y >= $this->subChunks->getSize()){
@@ -662,9 +587,6 @@ class Chunk{
/**
* Sets a subchunk in the chunk index
*
* @param int $y
* @param SubChunk|null $subChunk
*/
public function setSubChunk(int $y, ?SubChunk $subChunk) : void{
if($y < 0 or $y >= $this->subChunks->getSize()){
@@ -697,8 +619,6 @@ class Chunk{
* @param int $x 0-15
* @param int $y
* @param int $z 0-15
*
* @return int
*/
public static function blockHash(int $x, int $y, int $z) : int{
return ($y << 8) | (($z & 0x0f) << 4) | ($x & 0x0f);

View File

@@ -39,10 +39,7 @@ class SubChunk implements SubChunkInterface{
/**
* SubChunk constructor.
*
* @param int $default
* @param PalettedBlockArray[] $blocks
* @param LightArray|null $skyLight
* @param LightArray|null $blockLight
*/
public function __construct(int $default, array $blocks, ?LightArray $skyLight = null, ?LightArray $blockLight = null){
$this->defaultBlock = $default;

View File

@@ -29,34 +29,17 @@ interface SubChunkInterface{
* Returns whether this subchunk contains any non-air blocks.
* This function will do a slow check, usually by garbage collecting first.
* This is typically useful for disk saving.
*
* @return bool
*/
public function isEmptyAuthoritative() : bool;
/**
* Returns a non-authoritative bool to indicate whether the chunk contains any blocks.
* This is a fast check, but may be inaccurate if the chunk has been modified and not garbage-collected.
*
* @return bool
*/
public function isEmptyFast() : bool;
/**
* @param int $x
* @param int $y
* @param int $z
*
* @return int
*/
public function getFullBlock(int $x, int $y, int $z) : int;
/**
* @param int $x
* @param int $y
* @param int $z
* @param int $block
*/
public function setFullBlock(int $x, int $y, int $z, int $block) : void;
/**
@@ -64,31 +47,13 @@ interface SubChunkInterface{
*/
public function getBlockLayers() : array;
/**
* @param int $x
* @param int $z
*
* @return int
*/
public function getHighestBlockAt(int $x, int $z) : int;
/**
* @return LightArray
*/
public function getBlockSkyLightArray() : LightArray;
/**
* @param LightArray $data
*/
public function setBlockSkyLightArray(LightArray $data) : void;
/**
* @return LightArray
*/
public function getBlockLightArray() : LightArray;
/**
* @param LightArray $data
*/
public function setBlockLightArray(LightArray $data) : void;
}

View File

@@ -46,7 +46,6 @@ abstract class BaseWorldProvider implements WorldProvider{
}
/**
* @return WorldData
* @throws CorruptedWorldException
* @throws UnsupportedWorldFormatException
*/
@@ -56,18 +55,11 @@ abstract class BaseWorldProvider implements WorldProvider{
return $this->path;
}
/**
* @return WorldData
*/
public function getWorldData() : WorldData{
return $this->worldData;
}
/**
* @param int $chunkX
* @param int $chunkZ
*
* @return Chunk|null
* @throws CorruptedChunkException
*/
public function loadChunk(int $chunkX, int $chunkZ) : ?Chunk{
@@ -82,10 +74,6 @@ abstract class BaseWorldProvider implements WorldProvider{
}
/**
* @param int $chunkX
* @param int $chunkZ
*
* @return Chunk|null
* @throws CorruptedChunkException
*/
abstract protected function readChunk(int $chunkX, int $chunkZ) : ?Chunk;

View File

@@ -32,8 +32,6 @@ class ChunkUtils{
* Converts pre-MCPE-1.0 biome color array to biome ID array.
*
* @param int[] $array of biome color values
*
* @return string
*/
public static function convertBiomeColors(array $array) : string{
$result = str_repeat("\x00", 256);

View File

@@ -48,10 +48,6 @@ final class FastChunkSerializer{
/**
* Fast-serializes the chunk for passing between threads
* TODO: tiles and entities
*
* @param Chunk $chunk
*
* @return string
*/
public static function serialize(Chunk $chunk) : string{
$stream = new BinaryStream();
@@ -97,10 +93,6 @@ final class FastChunkSerializer{
/**
* Deserializes a fast-serialized chunk
*
* @param string $data
*
* @return Chunk
*/
public static function deserialize(string $data) : Chunk{
$stream = new BinaryStream($data);

View File

@@ -32,73 +32,42 @@ interface WorldData{
*/
public function save() : void;
/**
* @return string
*/
public function getName() : string;
/**
* Returns the generator name
*
* @return string
*/
public function getGenerator() : string;
/**
* @return array
*/
public function getGeneratorOptions() : array;
/**
* @return int
*/
public function getSeed() : int;
/**
* @return int
*/
public function getTime() : int;
/**
* @param int $value
*/
public function setTime(int $value) : void;
/**
* @return Vector3
*/
public function getSpawn() : Vector3;
/**
* @param Vector3 $pos
*/
public function setSpawn(Vector3 $pos) : void;
/**
* Returns the world difficulty. This will be one of the World constants.
* @return int
*/
public function getDifficulty() : int;
/**
* Sets the world difficulty.
*
* @param int $difficulty
*/
public function setDifficulty(int $difficulty) : void;
/**
* Returns the time in ticks to the next rain level change.
* @return int
*/
public function getRainTime() : int;
/**
* Sets the time in ticks to the next rain level change.
* @param int $ticks
*/
public function setRainTime(int $ticks) : void;
@@ -114,13 +83,11 @@ interface WorldData{
/**
* Returns the time in ticks to the next lightning level change.
* @return int
*/
public function getLightningTime() : int;
/**
* Sets the time in ticks to the next lightning level change.
* @param int $ticks
*/
public function setLightningTime(int $ticks) : void;

View File

@@ -31,7 +31,6 @@ use pocketmine\world\format\io\exception\UnsupportedWorldFormatException;
interface WorldProvider{
/**
* @param string $path
* @throws CorruptedWorldException
* @throws UnsupportedWorldFormatException
*/
@@ -39,34 +38,20 @@ interface WorldProvider{
/**
* Gets the build height limit of this world
*
* @return int
*/
public function getWorldHeight() : int;
/**
* @return string
*/
public function getPath() : string;
/**
* Tells if the path is a valid world.
* This must tell if the current format supports opening the files in the directory
*
* @param string $path
*
* @return bool
*/
public static function isValid(string $path) : bool;
/**
* Loads a chunk (usually from disk storage) and returns it. If the chunk does not exist, null is returned.
*
* @param int $chunkX
* @param int $chunkZ
*
* @return null|Chunk
*
* @throws CorruptedChunkException
*/
public function loadChunk(int $chunkX, int $chunkZ) : ?Chunk;
@@ -78,8 +63,6 @@ interface WorldProvider{
/**
* Returns information about the world
*
* @return WorldData
*/
public function getWorldData() : WorldData;
@@ -91,10 +74,6 @@ interface WorldProvider{
/**
* Returns a generator which yields all the chunks in this world.
*
* @param bool $skipCorrupted
*
* @param \Logger|null $logger
*
* @return \Generator|Chunk[]
* @throws CorruptedChunkException
*/
@@ -102,8 +81,6 @@ interface WorldProvider{
/**
* Returns the number of chunks in the provider. Used for world conversion time estimations.
*
* @return int
*/
public function calculateChunkCount() : int;
}

View File

@@ -47,8 +47,6 @@ abstract class WorldProviderManager{
/**
* Returns the default format used to generate new worlds.
*
* @return string
*/
public static function getDefault() : string{
return self::$default;
@@ -67,12 +65,6 @@ abstract class WorldProviderManager{
self::$default = $class;
}
/**
* @param string $class
*
* @param string $name
* @param bool $overwrite
*/
public static function addProvider(string $class, string $name, bool $overwrite = false) : void{
Utils::testValidInstance($class, WorldProvider::class);
@@ -88,8 +80,6 @@ abstract class WorldProviderManager{
/**
* Returns a WorldProvider class for this path, or null
*
* @param string $path
*
* @return string[]|WorldProvider[]
*/
public static function getMatchingProviders(string $path) : array{
@@ -112,10 +102,6 @@ abstract class WorldProviderManager{
/**
* Returns a WorldProvider by name, or null if not found
*
* @param string $name
*
* @return string|null
*/
public static function getProviderByName(string $name) : ?string{
return self::$providers[trim(strtolower($name))] ?? null;

View File

@@ -28,19 +28,11 @@ use pocketmine\world\format\Chunk;
interface WritableWorldProvider extends WorldProvider{
/**
* Generate the needed files in the path given
*
* @param string $path
* @param string $name
* @param int $seed
* @param string $generator
* @param array $options
*/
public static function generate(string $path, string $name, int $seed, string $generator, array $options = []) : void;
/**
* Saves a chunk (usually to disk).
*
* @param Chunk $chunk
*/
public function saveChunk(Chunk $chunk) : void;
}

View File

@@ -39,8 +39,6 @@ abstract class BaseNbtWorldData implements WorldData{
protected $compoundTag;
/**
* @param string $dataPath
*
* @throws CorruptedWorldException
* @throws UnsupportedWorldFormatException
*/
@@ -60,7 +58,6 @@ abstract class BaseNbtWorldData implements WorldData{
}
/**
* @return CompoundTag
* @throws CorruptedWorldException
* @throws UnsupportedWorldFormatException
*/

View File

@@ -108,9 +108,6 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
}
/**
* @param string $path
*
* @return \LevelDB
* @throws \LevelDBException
*/
private static function createDB(string $path) : \LevelDB{
@@ -197,9 +194,6 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
}
/**
* @param string $index
* @param int $chunkVersion
*
* @return PalettedBlockArray[]
*/
protected function deserializeLegacyExtraData(string $index, int $chunkVersion) : array{
@@ -232,10 +226,6 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
}
/**
* @param int $chunkX
* @param int $chunkZ
*
* @return Chunk|null
* @throws CorruptedChunkException
*/
protected function readChunk(int $chunkX, int $chunkZ) : ?Chunk{
@@ -490,8 +480,6 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
/**
* @param CompoundTag[] $targets
* @param string $index
* @param \LevelDBWriteBatch $write
*/
private function writeTags(array $targets, string $index, \LevelDBWriteBatch $write) : void{
if(!empty($targets)){
@@ -502,9 +490,6 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
}
}
/**
* @return \LevelDB
*/
public function getDatabase() : \LevelDB{
return $this->db;
}

View File

@@ -49,9 +49,6 @@ trait LegacyAnvilChunkTrait{
}
/**
* @param string $data
*
* @return Chunk
* @throws CorruptedChunkException
*/
protected function deserializeChunk(string $data) : Chunk{

View File

@@ -39,9 +39,6 @@ use function str_repeat;
class McRegion extends RegionWorldProvider{
/**
* @param Chunk $chunk
*
* @return string
* @throws \RuntimeException
*/
protected function serializeChunk(Chunk $chunk) : string{
@@ -49,9 +46,6 @@ class McRegion extends RegionWorldProvider{
}
/**
* @param string $data
*
* @return Chunk
* @throws CorruptedChunkException
*/
protected function deserializeChunk(string $data) : Chunk{

View File

@@ -111,10 +111,6 @@ class RegionLoader{
}
/**
* @param int $x
* @param int $z
*
* @return null|string
* @throws \InvalidArgumentException if invalid coordinates are given
* @throws CorruptedChunkException if chunk corruption is detected
*/
@@ -163,10 +159,6 @@ class RegionLoader{
}
/**
* @param int $x
* @param int $z
*
* @return bool
* @throws \InvalidArgumentException
*/
public function chunkExists(int $x, int $z) : bool{
@@ -174,10 +166,6 @@ class RegionLoader{
}
/**
* @param int $x
* @param int $z
* @param string $chunkData
*
* @throws ChunkException
* @throws \InvalidArgumentException
*/
@@ -207,9 +195,6 @@ class RegionLoader{
}
/**
* @param int $x
* @param int $z
*
* @throws \InvalidArgumentException
*/
public function removeChunk(int $x, int $z) : void{
@@ -219,10 +204,6 @@ class RegionLoader{
}
/**
* @param int $x
* @param int $z
*
* @return int
* @throws \InvalidArgumentException
*/
protected static function getChunkOffset(int $x, int $z) : int{
@@ -233,7 +214,6 @@ class RegionLoader{
}
/**
* @param int $offset
* @param int $x reference parameter
* @param int $z reference parameter
*/

View File

@@ -35,10 +35,6 @@ class RegionLocationTableEntry{
private $timestamp;
/**
* @param int $firstSector
* @param int $sectorCount
* @param int $timestamp
*
* @throws \InvalidArgumentException
*/
public function __construct(int $firstSector, int $sectorCount, int $timestamp){
@@ -53,16 +49,10 @@ class RegionLocationTableEntry{
$this->timestamp = $timestamp;
}
/**
* @return int
*/
public function getFirstSector() : int{
return $this->firstSector;
}
/**
* @return int
*/
public function getLastSector() : int{
return $this->firstSector + $this->sectorCount - 1;
}
@@ -75,23 +65,14 @@ class RegionLocationTableEntry{
return range($this->getFirstSector(), $this->getLastSector());
}
/**
* @return int
*/
public function getSectorCount() : int{
return $this->sectorCount;
}
/**
* @return int
*/
public function getTimestamp() : int{
return $this->timestamp;
}
/**
* @return bool
*/
public function isNull() : bool{
return $this->firstSector === 0 or $this->sectorCount === 0;
}

View File

@@ -51,13 +51,11 @@ abstract class RegionWorldProvider extends BaseWorldProvider{
/**
* Returns the file extension used for regions in this region-based format.
* @return string
*/
abstract protected static function getRegionFileExtension() : string;
/**
* Returns the storage version as per Minecraft PC world formats.
* @return int
*/
abstract protected static function getPcWorldFormatVersion() : int;
@@ -105,8 +103,6 @@ abstract class RegionWorldProvider extends BaseWorldProvider{
}
/**
* @param int $chunkX
* @param int $chunkZ
* @param int $regionX reference parameter
* @param int $regionZ reference parameter
*/
@@ -115,32 +111,17 @@ abstract class RegionWorldProvider extends BaseWorldProvider{
$regionZ = $chunkZ >> 5;
}
/**
* @param int $regionX
* @param int $regionZ
*
* @return RegionLoader|null
*/
protected function getRegion(int $regionX, int $regionZ) : ?RegionLoader{
return $this->regions[World::chunkHash($regionX, $regionZ)] ?? null;
}
/**
* Returns the path to a specific region file based on its X/Z coordinates
*
* @param int $regionX
* @param int $regionZ
*
* @return string
*/
protected function pathToRegion(int $regionX, int $regionZ) : string{
return $this->path . "/region/r.$regionX.$regionZ." . static::getRegionFileExtension();
}
/**
* @param int $regionX
* @param int $regionZ
*/
protected function loadRegion(int $regionX, int $regionZ) : void{
if(!isset($this->regions[$index = World::chunkHash($regionX, $regionZ)])){
$path = $this->pathToRegion($regionX, $regionZ);
@@ -183,17 +164,11 @@ abstract class RegionWorldProvider extends BaseWorldProvider{
abstract protected function serializeChunk(Chunk $chunk) : string;
/**
* @param string $data
*
* @return Chunk
* @throws CorruptedChunkException
*/
abstract protected function deserializeChunk(string $data) : Chunk;
/**
* @param string $context
* @param ListTag $list
*
* @return CompoundTag[]
* @throws CorruptedChunkException
*/
@@ -216,10 +191,6 @@ abstract class RegionWorldProvider extends BaseWorldProvider{
}
/**
* @param int $chunkX
* @param int $chunkZ
*
* @return Chunk|null
* @throws CorruptedChunkException
*/
protected function readChunk(int $chunkX, int $chunkZ) : ?Chunk{