mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
Block API typehints
This commit is contained in:
@ -375,7 +375,7 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
*
|
||||
* @return Block
|
||||
*/
|
||||
public static function get($id, $meta = 0, Position $pos = null){
|
||||
public static function get(int $id, int $meta = 0, Position $pos = null) : Block{
|
||||
try{
|
||||
$block = self::$fullList[($id << 4) | $meta];
|
||||
if($block !== null){
|
||||
@ -425,14 +425,14 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(){
|
||||
public function getName() : string{
|
||||
return $this->fallbackName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
final public function getId(){
|
||||
final public function getId() : int{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
@ -449,32 +449,32 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
final public function getDamage(){
|
||||
final public function getDamage() : int{
|
||||
return $this->meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $meta
|
||||
*/
|
||||
final public function setDamage($meta){
|
||||
final public function setDamage(int $meta){
|
||||
$this->meta = $meta & 0x0f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Places the Block, using block space and block target, and side. Returns if the block has been placed.
|
||||
*
|
||||
* @param Item $item
|
||||
* @param Block $block
|
||||
* @param Block $target
|
||||
* @param int $face
|
||||
* @param float $fx
|
||||
* @param float $fy
|
||||
* @param float $fz
|
||||
* @param Player $player = null
|
||||
* @param Item $item
|
||||
* @param Block $block
|
||||
* @param Block $target
|
||||
* @param int $face
|
||||
* @param float $fx
|
||||
* @param float $fy
|
||||
* @param float $fz
|
||||
* @param Player|null $player
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||
public function place(Item $item, Block $block, Block $target, int $face, float $fx, float $fy, float $fz, Player $player = null) : bool{
|
||||
return $this->getLevel()->setBlock($this, $this, true, true);
|
||||
}
|
||||
|
||||
@ -485,7 +485,7 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isBreakable(Item $item){
|
||||
public function isBreakable(Item $item) : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -494,9 +494,9 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
*
|
||||
* @param Item $item
|
||||
*
|
||||
* @return mixed
|
||||
* @return bool
|
||||
*/
|
||||
public function onBreak(Item $item){
|
||||
public function onBreak(Item $item) : bool{
|
||||
return $this->getLevel()->setBlock($this, new Air(), true, true);
|
||||
}
|
||||
|
||||
@ -505,56 +505,56 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
*
|
||||
* @param int $type
|
||||
*
|
||||
* @return int|bool
|
||||
* @return bool|int
|
||||
*/
|
||||
public function onUpdate($type){
|
||||
public function onUpdate(int $type){
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do actions when activated by Item. Returns if it has done anything
|
||||
*
|
||||
* @param Item $item
|
||||
* @param Player $player
|
||||
* @param Item $item
|
||||
* @param Player|null $player
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function onActivate(Item $item, Player $player = null){
|
||||
public function onActivate(Item $item, Player $player = null) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getHardness(){
|
||||
public function getHardness() : float{
|
||||
return 10;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getResistance(){
|
||||
public function getResistance() : float{
|
||||
return $this->getHardness() * 5;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getToolType(){
|
||||
public function getToolType() : int{
|
||||
return Tool::TYPE_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getFrictionFactor(){
|
||||
public function getFrictionFactor() : float{
|
||||
return 0.6;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int 0-15
|
||||
*/
|
||||
public function getLightLevel(){
|
||||
public function getLightLevel() : int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -583,45 +583,43 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
|
||||
/**
|
||||
* AKA: Block->isPlaceable
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canBePlaced(){
|
||||
public function canBePlaced() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function canBeReplaced(){
|
||||
public function canBeReplaced() : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isTransparent(){
|
||||
public function isTransparent() : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isSolid(){
|
||||
public function isSolid() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* AKA: Block->isFlowable
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canBeFlowedInto(){
|
||||
public function canBeFlowedInto() : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function hasEntityCollision(){
|
||||
public function hasEntityCollision() : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function canPassThrough(){
|
||||
public function canPassThrough() : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -671,7 +669,7 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getBreakTime(Item $item){
|
||||
public function getBreakTime(Item $item) : float{
|
||||
$base = $this->getHardness() * 1.5;
|
||||
if($this->canBeBrokenWith($item)){
|
||||
if($this->getToolType() === Tool::TYPE_SHEARS and $item->isShears()){
|
||||
@ -710,7 +708,7 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
return $base;
|
||||
}
|
||||
|
||||
public function canBeBrokenWith(Item $item){
|
||||
public function canBeBrokenWith(Item $item) : bool{
|
||||
return $this->getHardness() !== -1;
|
||||
}
|
||||
|
||||
@ -752,7 +750,7 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function collidesWithBB(AxisAlignedBB $bb){
|
||||
public function collidesWithBB(AxisAlignedBB $bb) : bool{
|
||||
$bb2 = $this->getBoundingBox();
|
||||
|
||||
return $bb2 !== null and $bb->intersectsWith($bb2);
|
||||
|
Reference in New Issue
Block a user