From 5dc52ad97d4530653a171e4a315a6e3aff37d12b Mon Sep 17 00:00:00 2001 From: Michael Yoo Date: Wed, 18 Dec 2013 20:05:04 +1030 Subject: [PATCH] Add PHPDoc Documentation to block types. --- src/material/block/DoorBlock.php | 48 ++++++++++++++++--- src/material/block/FallableBlock.php | 23 ++++++++-- src/material/block/FlowableBlock.php | 7 ++- src/material/block/GenericBlock.php | 61 +++++++++++++++++++++---- src/material/block/LiquidBlock.php | 7 ++- src/material/block/SolidBlock.php | 7 ++- src/material/block/StairBlock.php | 31 +++++++++++-- src/material/block/TransparentBlock.php | 7 ++- 8 files changed, 163 insertions(+), 28 deletions(-) diff --git a/src/material/block/DoorBlock.php b/src/material/block/DoorBlock.php index 6d6ac1d98..06c0c4bcb 100644 --- a/src/material/block/DoorBlock.php +++ b/src/material/block/DoorBlock.php @@ -20,12 +20,22 @@ */ class DoorBlock extends TransparentBlock{ - public function __construct($id, $meta = 0, $name = "Unknown"){ + /** + * @param int $id + * @param int $meta + * @param string $name + */ + public function __construct($id, $meta = 0, $name = "Unknown"){ parent::__construct($id, $meta, $name); $this->isSolid = false; } - public function onUpdate($type){ + /** + * @param int $type + * + * @return bool|int + */ + public function onUpdate($type){ if($type === BLOCK_UPDATE_NORMAL){ if($this->getSide(0)->getID() === AIR){ //Replace with common break method $this->level->setBlock($this, new AirBlock(), false); @@ -38,7 +48,19 @@ class DoorBlock extends TransparentBlock{ return false; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + /** + * @param Item $item + * @param Player $player + * @param Block $block + * @param Block $target + * @param integer $face + * @param integer $fx + * @param integer $fy + * @param integer $fz + * + * @return boolean + */ + public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ if($face === 1){ $blockUp = $this->getSide(1); $blockDown = $this->getSide(0); @@ -66,8 +88,14 @@ class DoorBlock extends TransparentBlock{ } return false; } - - public function onBreak(Item $item, Player $player){ + + /** + * @param Item $item + * @param Player $player + * + * @return boolean + */ + public function onBreak(Item $item, Player $player){ if(($this->meta & 0x08) === 0x08){ $down = $this->getSide(0); if($down->getID() === $this->id){ @@ -82,8 +110,14 @@ class DoorBlock extends TransparentBlock{ $this->level->setBlock($this, new AirBlock(), true, false, true); return true; } - - public function onActivate(Item $item, Player $player){ + + /** + * @param Item $item + * @param Player $player + * + * @return boolean + */ + public function onActivate(Item $item, Player $player){ if(($this->meta & 0x08) === 0x08){ //Top $down = $this->getSide(0); if($down->getID() === $this->id){ diff --git a/src/material/block/FallableBlock.php b/src/material/block/FallableBlock.php index b4c4bcabd..8b4a1e121 100644 --- a/src/material/block/FallableBlock.php +++ b/src/material/block/FallableBlock.php @@ -20,12 +20,29 @@ */ class FallableBlock extends SolidBlock{ - public function __construct($id, $meta = 0, $name = "Unknown"){ + /** + * @param int $id + * @param int $meta + * @param string $name + */ + public function __construct($id, $meta = 0, $name = "Unknown"){ parent::__construct($id, $meta, $name); $this->hasPhysics = true; } - - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + + /** + * @param Item $item + * @param Player $player + * @param Block $block + * @param Block $target + * @param int $face + * @param int $fx + * @param int $fy + * @param int $fz + * + * @return mixed + */ + public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $ret = $this->level->setBlock($this, $this, true, false, true); ServerAPI::request()->api->block->blockUpdate(clone $this, BLOCK_UPDATE_NORMAL); return $ret; diff --git a/src/material/block/FlowableBlock.php b/src/material/block/FlowableBlock.php index 0811320ae..d6b58b385 100644 --- a/src/material/block/FlowableBlock.php +++ b/src/material/block/FlowableBlock.php @@ -20,7 +20,12 @@ */ class FlowableBlock extends TransparentBlock{ - public function __construct($id, $meta = 0, $name = "Unknown"){ + /** + * @param int $id + * @param int $meta + * @param string $name + */ + public function __construct($id, $meta = 0, $name = "Unknown"){ parent::__construct($id, $meta, $name); $this->isFlowable = true; $this->isFullBlock = false; diff --git a/src/material/block/GenericBlock.php b/src/material/block/GenericBlock.php index c2c752d93..6e4e01a2d 100644 --- a/src/material/block/GenericBlock.php +++ b/src/material/block/GenericBlock.php @@ -21,22 +21,57 @@ class GenericBlock extends Block{ - public function __construct($id, $meta = 0, $name = "Unknown"){ + /** + * @param int $id + * @param int $meta + * @param string $name + */ + public function __construct($id, $meta = 0, $name = "Unknown"){ parent::__construct($id, $meta, $name); - } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + } + + /** + * @param Item $item + * @param Player $player + * @param Block $block + * @param Block $target + * @param integer $face + * @param integer $fx + * @param integer $fy + * @param integer $fz + * + * @return mixed + */ + public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ return $this->level->setBlock($this, $this, true, false, true); } - - public function isBreakable(Item $item, Player $player){ + + /** + * @param Item $item + * @param Player $player + * + * @return boolean + */ + public function isBreakable(Item $item, Player $player){ return ($this->breakable); } - - public function onBreak(Item $item, Player $player){ + + /** + * @param Item $item + * @param Player $player + * + * @return mixed + */ + public function onBreak(Item $item, Player $player){ return $this->level->setBlock($this, new AirBlock(), true, false, true); } - - public function onUpdate($type){ + + /** + * @param integer $type + * + * @return boolean + */ + public function onUpdate($type){ if($this->hasPhysics === true and $type === BLOCK_UPDATE_NORMAL){ $down = $this->getSide(0); if($down->getID() === AIR or ($down instanceof LiquidBlock)){ @@ -57,7 +92,13 @@ class GenericBlock extends Block{ return false; } - public function onActivate(Item $item, Player $player){ + /** + * @param Item $item + * @param Player $player + * + * @return boolean + */ + public function onActivate(Item $item, Player $player){ return $this->isActivable; } } \ No newline at end of file diff --git a/src/material/block/LiquidBlock.php b/src/material/block/LiquidBlock.php index e88e5749d..1da2aca84 100644 --- a/src/material/block/LiquidBlock.php +++ b/src/material/block/LiquidBlock.php @@ -20,7 +20,12 @@ */ class LiquidBlock extends TransparentBlock{ - public function __construct($id, $meta = 0, $name = "Unknown"){ + /** + * @param int $id + * @param int $meta + * @param string $name + */ + public function __construct($id, $meta = 0, $name = "Unknown"){ parent::__construct($id, $meta, $name); $this->isLiquid = true; $this->breakable = false; diff --git a/src/material/block/SolidBlock.php b/src/material/block/SolidBlock.php index af0d81afe..eee322440 100644 --- a/src/material/block/SolidBlock.php +++ b/src/material/block/SolidBlock.php @@ -20,7 +20,12 @@ */ class SolidBlock extends GenericBlock{ - public function __construct($id, $meta = 0, $name = "Unknown"){ + /** + * @param int $id + * @param int $meta + * @param string $name + */ + public function __construct($id, $meta = 0, $name = "Unknown"){ parent::__construct($id, $meta, $name); $this->isSolid = true; $this->isFullBlock = true; diff --git a/src/material/block/StairBlock.php b/src/material/block/StairBlock.php index 87897e53a..e39ed27e2 100644 --- a/src/material/block/StairBlock.php +++ b/src/material/block/StairBlock.php @@ -20,7 +20,12 @@ */ class StairBlock extends TransparentBlock{ - public function __construct($id, $meta = 0, $name = "Unknown"){ + /** + * @param int $id + * @param int $meta + * @param string $name + */ + public function __construct($id, $meta = 0, $name = "Unknown"){ parent::__construct($id, $meta, $name); if(($this->meta & 0x04) === 0x04){ $this->isFullBlock = true; @@ -30,7 +35,19 @@ class StairBlock extends TransparentBlock{ $this->hardness = 30; } - public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + /** + * @param Item $item + * @param Player $player + * @param Block $block + * @param Block $target + * @param int $face + * @param int $fx + * @param int $fy + * @param int $fz + * + * @return bool|mixed + */ + public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $faces = array( 0 => 0, 1 => 2, @@ -44,8 +61,14 @@ class StairBlock extends TransparentBlock{ $this->level->setBlock($block, $this, true, false, true); return true; } - - public function getDrops(Item $item, Player $player){ + + /** + * @param Item $item + * @param Player $player + * + * @return array + */ + public function getDrops(Item $item, Player $player){ if($item->isPickaxe() >= 1){ return array( array($this->id, 0, 1), diff --git a/src/material/block/TransparentBlock.php b/src/material/block/TransparentBlock.php index 33e19d6fa..0f0c438da 100644 --- a/src/material/block/TransparentBlock.php +++ b/src/material/block/TransparentBlock.php @@ -20,7 +20,12 @@ */ class TransparentBlock extends GenericBlock{ - public function __construct($id, $meta = 0, $name = "Unknown"){ + /** + * @param int $id + * @param int $meta + * @param string $name + */ + public function __construct($id, $meta = 0, $name = "Unknown"){ parent::__construct($id, $meta, $name); $this->isActivable = false; $this->breakable = true;