Add PHPDoc Documentation to block types.

This commit is contained in:
Michael Yoo 2013-12-18 20:05:04 +10:30
parent 5eed43ddd0
commit 5dc52ad97d
8 changed files with 163 additions and 28 deletions

View File

@ -20,12 +20,22 @@
*/ */
class DoorBlock extends TransparentBlock{ 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); parent::__construct($id, $meta, $name);
$this->isSolid = false; $this->isSolid = false;
} }
public function onUpdate($type){ /**
* @param int $type
*
* @return bool|int
*/
public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){ if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->getID() === AIR){ //Replace with common break method if($this->getSide(0)->getID() === AIR){ //Replace with common break method
$this->level->setBlock($this, new AirBlock(), false); $this->level->setBlock($this, new AirBlock(), false);
@ -38,7 +48,19 @@ class DoorBlock extends TransparentBlock{
return false; 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){ if($face === 1){
$blockUp = $this->getSide(1); $blockUp = $this->getSide(1);
$blockDown = $this->getSide(0); $blockDown = $this->getSide(0);
@ -67,7 +89,13 @@ class DoorBlock extends TransparentBlock{
return false; 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){ if(($this->meta & 0x08) === 0x08){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() === $this->id){ if($down->getID() === $this->id){
@ -83,7 +111,13 @@ class DoorBlock extends TransparentBlock{
return 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 if(($this->meta & 0x08) === 0x08){ //Top
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() === $this->id){ if($down->getID() === $this->id){

View File

@ -20,12 +20,29 @@
*/ */
class FallableBlock extends SolidBlock{ 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); parent::__construct($id, $meta, $name);
$this->hasPhysics = true; $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); $ret = $this->level->setBlock($this, $this, true, false, true);
ServerAPI::request()->api->block->blockUpdate(clone $this, BLOCK_UPDATE_NORMAL); ServerAPI::request()->api->block->blockUpdate(clone $this, BLOCK_UPDATE_NORMAL);
return $ret; return $ret;

View File

@ -20,7 +20,12 @@
*/ */
class FlowableBlock extends TransparentBlock{ 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); parent::__construct($id, $meta, $name);
$this->isFlowable = true; $this->isFlowable = true;
$this->isFullBlock = false; $this->isFullBlock = false;

View File

@ -21,22 +21,57 @@
class GenericBlock extends Block{ 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); 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); 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); 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); 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){ if($this->hasPhysics === true and $type === BLOCK_UPDATE_NORMAL){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() === AIR or ($down instanceof LiquidBlock)){ if($down->getID() === AIR or ($down instanceof LiquidBlock)){
@ -57,7 +92,13 @@ class GenericBlock extends Block{
return false; 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; return $this->isActivable;
} }
} }

View File

@ -20,7 +20,12 @@
*/ */
class LiquidBlock extends TransparentBlock{ 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); parent::__construct($id, $meta, $name);
$this->isLiquid = true; $this->isLiquid = true;
$this->breakable = false; $this->breakable = false;

View File

@ -20,7 +20,12 @@
*/ */
class SolidBlock extends GenericBlock{ 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); parent::__construct($id, $meta, $name);
$this->isSolid = true; $this->isSolid = true;
$this->isFullBlock = true; $this->isFullBlock = true;

View File

@ -20,7 +20,12 @@
*/ */
class StairBlock extends TransparentBlock{ 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); parent::__construct($id, $meta, $name);
if(($this->meta & 0x04) === 0x04){ if(($this->meta & 0x04) === 0x04){
$this->isFullBlock = true; $this->isFullBlock = true;
@ -30,7 +35,19 @@ class StairBlock extends TransparentBlock{
$this->hardness = 30; $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( $faces = array(
0 => 0, 0 => 0,
1 => 2, 1 => 2,
@ -45,7 +62,13 @@ class StairBlock extends TransparentBlock{
return 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){ if($item->isPickaxe() >= 1){
return array( return array(
array($this->id, 0, 1), array($this->id, 0, 1),

View File

@ -20,7 +20,12 @@
*/ */
class TransparentBlock extends GenericBlock{ 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); parent::__construct($id, $meta, $name);
$this->isActivable = false; $this->isActivable = false;
$this->breakable = true; $this->breakable = true;