Block API typehints

This commit is contained in:
Dylan K. Taylor 2017-08-17 13:50:19 +01:00
parent f6c31680f6
commit 83af4dcd59
162 changed files with 665 additions and 667 deletions

View File

@ -27,7 +27,7 @@ class ActivatorRail extends Rail{
protected $id = self::ACTIVATOR_RAIL;
public function getName(){
public function getName() : string{
return "Activator Rail";
}
}

View File

@ -34,35 +34,35 @@ class Air extends Transparent{
protected $id = self::AIR;
protected $meta = 0;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Air";
}
public function canPassThrough(){
public function canPassThrough() : bool{
return true;
}
public function isBreakable(Item $item){
public function isBreakable(Item $item) : bool{
return false;
}
public function canBeFlowedInto(){
public function canBeFlowedInto() : bool{
return true;
}
public function canBeReplaced(){
public function canBeReplaced() : bool{
return true;
}
public function canBePlaced(){
public function canBePlaced() : bool{
return false;
}
public function isSolid(){
public function isSolid() : bool{
return false;
}
@ -70,11 +70,11 @@ class Air extends Transparent{
return null;
}
public function getHardness(){
public function getHardness() : float{
return -1;
}
public function getResistance(){
public function getResistance() : float{
return 0;
}

View File

@ -36,23 +36,23 @@ class Anvil extends Fallable{
protected $id = self::ANVIL;
public function isSolid(){
public function isSolid() : bool{
return false;
}
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 5;
}
public function getResistance(){
public function getResistance() : float{
return 6000;
}
public function getName(){
public function getName() : string{
static $names = [
self::TYPE_NORMAL => "Anvil",
self::TYPE_SLIGHTLY_DAMAGED => "Slightly Damaged Anvil",
@ -61,11 +61,11 @@ class Anvil extends Fallable{
return $names[$this->meta & 0x0c] ?? "Anvil";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
if($player instanceof Player){
$player->addWindow(new AnvilInventory($this));
}
@ -73,10 +73,10 @@ class Anvil extends Fallable{
return true;
}
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{
$direction = ($player !== null ? $player->getDirection() : 0) & 0x03;
$this->meta = ($this->meta & 0x0c) | $direction;
$this->getLevel()->setBlock($block, $this, true, true);
return $this->getLevel()->setBlock($block, $this, true, true);
}
public function getDrops(Item $item){

View File

@ -43,15 +43,15 @@ class Bed extends Transparent{
protected $id = self::BED_BLOCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 0.2;
}
public function getName(){
public function getName() : string{
return "Bed Block";
}
@ -135,7 +135,7 @@ class Bed extends Transparent{
return null;
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
if($player !== null){
$other = $this->getOtherHalf();
if($other === null){
@ -172,7 +172,7 @@ class Bed extends Transparent{
}
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{
$down = $this->getSide(Vector3::SIDE_DOWN);
if(!$down->isTransparent()){
$meta = (($player instanceof Player ? $player->getDirection() : 0) - 1) & 0x03;
@ -203,7 +203,7 @@ class Bed extends Transparent{
return false;
}
public function onBreak(Item $item){
public function onBreak(Item $item) : bool{
$this->getLevel()->setBlock($this, Block::get(Block::AIR), true, true);
if(($other = $this->getOtherHalf()) !== null){
$this->getLevel()->useBreakOn($other); //make sure tiles get removed

View File

@ -29,23 +29,23 @@ class Bedrock extends Solid{
protected $id = self::BEDROCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Bedrock";
}
public function getHardness(){
public function getHardness() : float{
return -1;
}
public function getResistance(){
public function getResistance() : float{
return 18000000;
}
public function isBreakable(Item $item){
public function isBreakable(Item $item) : bool{
return false;
}

View File

@ -29,11 +29,11 @@ class Beetroot extends Crops{
protected $id = self::BEETROOT_BLOCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Beetroot Block";
}

View File

@ -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,14 +449,14 @@ 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;
}
@ -470,11 +470,11 @@ class Block extends Position implements BlockIds, Metadatable{
* @param float $fx
* @param float $fy
* @param float $fz
* @param Player $player = null
* @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,9 +505,9 @@ 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;
}
@ -515,46 +515,46 @@ class Block extends Position implements BlockIds, Metadatable{
* Do actions when activated by Item. Returns if it has done anything
*
* @param Item $item
* @param Player $player
* @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);

View File

@ -30,19 +30,19 @@ class Bookshelf extends Solid{
protected $id = self::BOOKSHELF;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Bookshelf";
}
public function getHardness(){
public function getHardness() : float{
return 1.5;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_AXE;
}

View File

@ -29,19 +29,19 @@ class BrewingStand extends Transparent{
protected $id = self::BREWING_STAND_BLOCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Brewing Stand";
}
public function getHardness(){
public function getHardness() : float{
return 0.5;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
}

View File

@ -29,23 +29,23 @@ class BrickStairs extends Stair{
protected $id = self::BRICK_STAIRS;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 2;
}
public function getResistance(){
public function getResistance() : float{
return 30;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getName(){
public function getName() : string{
return "Brick Stairs";
}

View File

@ -30,23 +30,23 @@ class Bricks extends Solid{
protected $id = self::BRICK_BLOCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 2;
}
public function getResistance(){
public function getResistance() : float{
return 30;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getName(){
public function getName() : string{
return "Bricks";
}

View File

@ -32,19 +32,19 @@ class BrownMushroom extends Flowable{
protected $id = self::BROWN_MUSHROOM;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Brown Mushroom";
}
public function getLightLevel(){
public function getLightLevel() : int{
return 1;
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(Vector3::SIDE_DOWN)->isTransparent() === true){
$this->getLevel()->useBreakOn($this);
@ -56,7 +56,7 @@ class BrownMushroom extends Flowable{
return false;
}
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{
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->isTransparent() === false){
$this->getLevel()->setBlock($block, $this, true, true);

View File

@ -38,27 +38,27 @@ class BurningFurnace extends Solid{
protected $id = self::BURNING_FURNACE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Burning Furnace";
}
public function getHardness(){
public function getHardness() : float{
return 3.5;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getLightLevel(){
public function getLightLevel() : int{
return 13;
}
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{
$faces = [
0 => 4,
1 => 2,
@ -91,7 +91,7 @@ class BurningFurnace extends Solid{
return true;
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
if($player instanceof Player){
$furnace = $this->getLevel()->getTile($this);
if(!($furnace instanceof TileFurnace)){

View File

@ -38,19 +38,19 @@ class Cactus extends Transparent{
protected $id = self::CACTUS;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 0.4;
}
public function hasEntityCollision(){
public function hasEntityCollision() : bool{
return true;
}
public function getName(){
public function getName() : string{
return "Cactus";
}
@ -71,7 +71,7 @@ class Cactus extends Transparent{
$entity->attack($ev->getFinalDamage(), $ev);
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() !== self::SAND and $down->getId() !== self::CACTUS){
@ -108,7 +108,7 @@ class Cactus extends Transparent{
return false;
}
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{
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() === self::SAND or $down->getId() === self::CACTUS){
$block0 = $this->getSide(Vector3::SIDE_NORTH);

View File

@ -36,15 +36,15 @@ class Cake extends Transparent implements FoodSource{
protected $id = self::CAKE_BLOCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 0.5;
}
public function getName(){
public function getName() : string{
return "Cake Block";
}
@ -62,7 +62,7 @@ class Cake extends Transparent implements FoodSource{
);
}
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{
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() !== self::AIR){
$this->getLevel()->setBlock($block, $this, true, true);
@ -73,7 +73,7 @@ class Cake extends Transparent implements FoodSource{
return false;
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(Vector3::SIDE_DOWN)->getId() === self::AIR){ //Replace with common break method
$this->getLevel()->setBlock($this, new Air(), true);
@ -89,7 +89,7 @@ class Cake extends Transparent implements FoodSource{
return [];
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
if($player instanceof Player and $player->getHealth() < $player->getMaxHealth()){
$ev = new EntityEatBlockEvent($player, $this);

View File

@ -34,19 +34,19 @@ class Carpet extends Flowable{
protected $id = self::CARPET;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 0.1;
}
public function isSolid(){
public function isSolid() : bool{
return true;
}
public function getName(){
public function getName() : string{
return ColorBlockMetaHelper::getColorFromMeta($this->meta) . " Carpet";
}
@ -62,7 +62,7 @@ class Carpet extends Flowable{
);
}
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{
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() !== self::AIR){
$this->getLevel()->setBlock($block, $this, true, true);
@ -73,7 +73,7 @@ class Carpet extends Flowable{
return false;
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(Vector3::SIDE_DOWN)->getId() === self::AIR){
$this->getLevel()->useBreakOn($this);

View File

@ -29,11 +29,11 @@ class Carrot extends Crops{
protected $id = self::CARROT_BLOCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Carrot Block";
}

View File

@ -40,19 +40,19 @@ class Chest extends Transparent{
protected $id = self::CHEST;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 2.5;
}
public function getName(){
public function getName() : string{
return "Chest";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_AXE;
}
@ -67,7 +67,7 @@ class Chest extends Transparent{
);
}
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{
$faces = [
0 => 4,
1 => 2,
@ -124,7 +124,7 @@ class Chest extends Transparent{
return true;
}
public function onBreak(Item $item){
public function onBreak(Item $item) : bool{
$t = $this->getLevel()->getTile($this);
if($t instanceof TileChest){
$t->unpair();
@ -134,7 +134,7 @@ class Chest extends Transparent{
return true;
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
if($player instanceof Player){
$top = $this->getSide(Vector3::SIDE_UP);
if($top->isTransparent() !== true){

View File

@ -30,19 +30,19 @@ class Clay extends Solid{
protected $id = self::CLAY_BLOCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 0.6;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_SHOVEL;
}
public function getName(){
public function getName() : string{
return "Clay Block";
}

View File

@ -30,19 +30,19 @@ class Coal extends Solid{
protected $id = self::COAL_BLOCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 5;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getName(){
public function getName() : string{
return "Coal Block";
}

View File

@ -30,19 +30,19 @@ class CoalOre extends Solid{
protected $id = self::COAL_ORE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 3;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getName(){
public function getName() : string{
return "Coal Ore";
}

View File

@ -30,19 +30,19 @@ class Cobblestone extends Solid{
protected $id = self::COBBLESTONE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getName(){
public function getName() : string{
return "Cobblestone";
}
public function getHardness(){
public function getHardness() : float{
return 2;
}

View File

@ -29,19 +29,19 @@ class CobblestoneStairs extends Stair{
protected $id = self::COBBLESTONE_STAIRS;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 2;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getName(){
public function getName() : string{
return "Cobblestone Stairs";
}

View File

@ -33,23 +33,23 @@ class CobblestoneWall extends Transparent{
protected $id = self::COBBLESTONE_WALL;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function isSolid(){
public function isSolid() : bool{
return false;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getHardness(){
public function getHardness() : float{
return 2;
}
public function getName(){
public function getName() : string{
if($this->meta === 0x01){
return "Mossy Cobblestone Wall";
}

View File

@ -31,23 +31,23 @@ class Cobweb extends Flowable{
protected $id = self::COBWEB;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function hasEntityCollision(){
public function hasEntityCollision() : bool{
return true;
}
public function getName(){
public function getName() : string{
return "Cobweb";
}
public function getHardness(){
public function getHardness() : float{
return 4;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_SWORD;
}

View File

@ -27,11 +27,11 @@ class CocoaBlock extends Solid{
protected $id = self::COCOA_BLOCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Cocoa Block";
}
}

View File

@ -31,23 +31,23 @@ class CraftingTable extends Solid{
protected $id = self::CRAFTING_TABLE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 2.5;
}
public function getName(){
public function getName() : string{
return "Crafting Table";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_AXE;
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
if($player instanceof Player){
$player->craftingType = 1;
}

View File

@ -32,7 +32,7 @@ use pocketmine\Server;
abstract class Crops extends Flowable{
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{
if($block->getSide(Vector3::SIDE_DOWN)->getId() === Block::FARMLAND){
$this->getLevel()->setBlock($block, $this, true, true);
@ -43,7 +43,7 @@ abstract class Crops extends Flowable{
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
if($item->getId() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal
$block = clone $this;
$block->meta += mt_rand(2, 5);
@ -65,7 +65,7 @@ abstract class Crops extends Flowable{
return false;
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(Vector3::SIDE_DOWN)->getId() !== Block::FARMLAND){
$this->getLevel()->useBreakOn($this);

View File

@ -32,16 +32,16 @@ class Dandelion extends Flowable{
protected $id = self::DANDELION;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Dandelion";
}
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{
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() === 2 or $down->getId() === 3 or $down->getId() === 60){
$this->getLevel()->setBlock($block, $this, true, true);
@ -52,7 +52,7 @@ class Dandelion extends Flowable{
return false;
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(Vector3::SIDE_DOWN)->isTransparent() === true){
$this->getLevel()->useBreakOn($this);

View File

@ -27,15 +27,15 @@ class DaylightSensor extends Transparent{
protected $id = self::DAYLIGHT_SENSOR;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Daylight Sensor";
}
public function getHardness(){
public function getHardness() : float{
return 0.2;
}

View File

@ -30,16 +30,16 @@ class DeadBush extends Flowable{
protected $id = self::DEAD_BUSH;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Dead Bush";
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(Vector3::SIDE_DOWN)->isTransparent() === true){
$this->getLevel()->useBreakOn($this);

View File

@ -27,7 +27,7 @@ class DetectorRail extends Rail{
protected $id = self::DETECTOR_RAIL;
public function getName(){
public function getName() : string{
return "Detector Rail";
}
}

View File

@ -30,19 +30,19 @@ class Diamond extends Solid{
protected $id = self::DIAMOND_BLOCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 5;
}
public function getName(){
public function getName() : string{
return "Diamond Block";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}

View File

@ -30,19 +30,19 @@ class DiamondOre extends Solid{
protected $id = self::DIAMOND_ORE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 3;
}
public function getName(){
public function getName() : string{
return "Diamond Ore";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}

View File

@ -31,23 +31,23 @@ class Dirt extends Solid{
protected $id = self::DIRT;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 0.5;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_SHOVEL;
}
public function getName(){
public function getName() : string{
return "Dirt";
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
if($item->isHoe()){
$item->useOn($this);
$this->getLevel()->setBlock($this, Block::get(Block::FARMLAND, 0), true);

View File

@ -33,7 +33,7 @@ use pocketmine\Player;
abstract class Door extends Transparent{
public function isSolid(){
public function isSolid() : bool{
return false;
}
@ -201,7 +201,7 @@ abstract class Door extends Transparent{
return $bb;
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(Vector3::SIDE_DOWN)->getId() === self::AIR){ //Replace with common break method
$this->getLevel()->setBlock($this, new Air(), false);
@ -216,7 +216,7 @@ abstract class Door extends Transparent{
return false;
}
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{
if($face === 1){
$blockUp = $this->getSide(Vector3::SIDE_UP);
$blockDown = $this->getSide(Vector3::SIDE_DOWN);
@ -246,7 +246,7 @@ abstract class Door extends Transparent{
return false;
}
public function onBreak(Item $item){
public function onBreak(Item $item) : bool{
if(($this->getDamage() & 0x08) === 0x08){
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() === $this->getId()){
@ -263,7 +263,7 @@ abstract class Door extends Transparent{
return true;
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
if(($this->getDamage() & 0x08) === 0x08){ //Top
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() === $this->getId()){

View File

@ -33,15 +33,15 @@ class DoublePlant extends Flowable{
protected $id = self::DOUBLE_PLANT;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function canBeReplaced(){
public function canBeReplaced() : bool{
return $this->meta === 2 or $this->meta === 3; //grass or fern
}
public function getName(){
public function getName() : string{
static $names = [
0 => "Sunflower",
1 => "Lilac",
@ -53,7 +53,7 @@ class DoublePlant extends Flowable{
return $names[$this->meta & 0x07] ?? "";
}
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{
$id = $block->getSide(Vector3::SIDE_DOWN)->getId();
if(($id === Block::GRASS or $id === Block::DIRT) and $block->getSide(Vector3::SIDE_UP)->canBeReplaced()){
$this->getLevel()->setBlock($block, $this, false, false);
@ -83,7 +83,7 @@ class DoublePlant extends Flowable{
);
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
$down = $this->getSide(Vector3::SIDE_DOWN);
if(!$this->isValidHalfPlant() or (($this->meta & self::BITFLAG_TOP) === 0 and $down->isTransparent())){
@ -96,7 +96,7 @@ class DoublePlant extends Flowable{
return false;
}
public function onBreak(Item $item){
public function onBreak(Item $item) : bool{
if(parent::onBreak($item) and $this->isValidHalfPlant()){
return $this->getLevel()->setBlock($this->getSide(($this->meta & self::BITFLAG_TOP) !== 0 ? Vector3::SIDE_DOWN : Vector3::SIDE_UP), Block::get(Block::AIR));
}

View File

@ -30,19 +30,19 @@ class DoubleStoneSlab extends Solid{
protected $id = self::DOUBLE_STONE_SLAB;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 2;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getName(){
public function getName() : string{
static $names = [
0 => "Stone",
1 => "Sandstone",

View File

@ -30,19 +30,19 @@ class DoubleWoodenSlab extends Solid{
protected $id = self::DOUBLE_WOODEN_SLAB;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 2;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_AXE;
}
public function getName(){
public function getName() : string{
static $names = [
0 => "Oak",
1 => "Spruce",

View File

@ -30,19 +30,19 @@ class Emerald extends Solid{
protected $id = self::EMERALD_BLOCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 5;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getName(){
public function getName() : string{
return "Emerald Block";
}

View File

@ -30,19 +30,19 @@ class EmeraldOre extends Solid{
protected $id = self::EMERALD_ORE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Emerald Ore";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getHardness(){
public function getHardness() : float{
return 3;
}

View File

@ -36,11 +36,11 @@ class EnchantingTable extends Transparent{
protected $id = self::ENCHANTING_TABLE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
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{
$this->getLevel()->setBlock($block, $this, true, true);
$nbt = new CompoundTag("", [
new StringTag("id", Tile::ENCHANT_TABLE),
@ -64,23 +64,23 @@ class EnchantingTable extends Transparent{
return true;
}
public function getHardness(){
public function getHardness() : float{
return 5;
}
public function getResistance(){
public function getResistance() : float{
return 6000;
}
public function getName(){
public function getName() : string{
return "Enchanting Table";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
if($player instanceof Player){
//TODO lock

View File

@ -30,27 +30,27 @@ class EndPortalFrame extends Solid{
protected $id = self::END_PORTAL_FRAME;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getLightLevel(){
public function getLightLevel() : int{
return 1;
}
public function getName(){
public function getName() : string{
return "End Portal Frame";
}
public function getHardness(){
public function getHardness() : float{
return -1;
}
public function getResistance(){
public function getResistance() : float{
return 18000000;
}
public function isBreakable(Item $item){
public function isBreakable(Item $item) : bool{
return false;
}

View File

@ -29,19 +29,19 @@ class EndStone extends Solid{
protected $id = self::END_STONE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "End Stone";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getHardness(){
public function getHardness() : float{
return 3;
}
}

View File

@ -35,7 +35,7 @@ use pocketmine\nbt\tag\ListTag;
abstract class Fallable extends Solid{
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() === self::AIR or ($down instanceof Liquid)){

View File

@ -31,19 +31,19 @@ class Farmland extends Transparent{
protected $id = self::FARMLAND;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Farmland";
}
public function getHardness(){
public function getHardness() : float{
return 0.6;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_SHOVEL;
}

View File

@ -37,20 +37,20 @@ class Fence extends Transparent{
protected $id = self::FENCE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 2;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_AXE;
}
public function getName(){
public function getName() : string{
static $names = [
self::FENCE_OAK => "Oak Fence",
self::FENCE_SPRUCE => "Spruce Fence",

View File

@ -31,11 +31,11 @@ use pocketmine\Player;
class FenceGate extends Transparent{
public function getHardness(){
public function getHardness() : float{
return 2;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_AXE;
}
@ -68,7 +68,7 @@ class FenceGate extends Transparent{
}
}
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{
$this->meta = ($player instanceof Player ? ($player->getDirection() - 1) & 0x03 : 0);
$this->getLevel()->setBlock($block, $this, true, true);
@ -81,7 +81,7 @@ class FenceGate extends Transparent{
];
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
$this->meta = (($this->meta ^ 0x04) & ~0x02);
if($player !== null){

View File

@ -37,27 +37,27 @@ class Fire extends Flowable{
protected $id = self::FIRE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function hasEntityCollision(){
public function hasEntityCollision() : bool{
return true;
}
public function getName(){
public function getName() : string{
return "Fire Block";
}
public function getLightLevel(){
public function getLightLevel() : int{
return 15;
}
public function isBreakable(Item $item){
public function isBreakable(Item $item) : bool{
return false;
}
public function canBeReplaced(){
public function canBeReplaced() : bool{
return true;
}
@ -79,7 +79,7 @@ class Fire extends Flowable{
return [];
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
for($s = 0; $s <= 5; ++$s){
$side = $this->getSide($s);

View File

@ -25,19 +25,19 @@ namespace pocketmine\block;
abstract class Flowable extends Transparent{
public function canBeFlowedInto(){
public function canBeFlowedInto() : bool{
return true;
}
public function getHardness(){
public function getHardness() : float{
return 0;
}
public function getResistance(){
public function getResistance() : float{
return 0;
}
public function isSolid(){
public function isSolid() : bool{
return false;
}

View File

@ -41,11 +41,11 @@ class Flower extends Flowable{
protected $id = self::RED_FLOWER;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
static $names = [
self::TYPE_POPPY => "Poppy",
self::TYPE_BLUE_ORCHID => "Blue Orchid",
@ -60,7 +60,7 @@ class Flower extends Flowable{
return $names[$this->meta] ?? "Unknown";
}
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{
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() === Block::GRASS or $down->getId() === Block::DIRT or $down->getId() === Block::FARMLAND){
$this->getLevel()->setBlock($block, $this, true);
@ -71,7 +71,7 @@ class Flower extends Flowable{
return false;
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(Vector3::SIDE_DOWN)->isTransparent()){
$this->getLevel()->useBreakOn($this);

View File

@ -42,11 +42,11 @@ class FlowerPot extends Flowable{
protected $id = self::FLOWER_POT_BLOCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Flower Pot Block";
}
@ -61,7 +61,7 @@ class FlowerPot extends Flowable{
);
}
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{
if($this->getSide(Vector3::SIDE_DOWN)->isTransparent()){
return false;
}
@ -87,7 +87,7 @@ class FlowerPot extends Flowable{
return true;
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(Vector3::SIDE_DOWN)->isTransparent() === true){
$this->getLevel()->useBreakOn($this);
@ -99,7 +99,7 @@ class FlowerPot extends Flowable{
return false;
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
$pot = $this->getLevel()->getTile($this);
if(!($pot instanceof TileFlowerPot)){
return false;

View File

@ -28,11 +28,11 @@ class Furnace extends BurningFurnace{
protected $id = self::FURNACE;
public function getName(){
public function getName() : string{
return "Furnace";
}
public function getLightLevel(){
public function getLightLevel() : int{
return 0;
}
}

View File

@ -29,15 +29,15 @@ class Glass extends Transparent{
protected $id = self::GLASS;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Glass";
}
public function getHardness(){
public function getHardness() : float{
return 0.3;
}

View File

@ -29,15 +29,15 @@ class GlassPane extends Thin{
protected $id = self::GLASS_PANE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Glass Pane";
}
public function getHardness(){
public function getHardness() : float{
return 0.3;
}

View File

@ -30,15 +30,15 @@ use pocketmine\Player;
class GlazedTerracotta extends Solid{
public function getHardness(){
public function getHardness() : float{
return 1.4;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
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{
if($player !== null){
$faces = [
0 => 4,

View File

@ -28,15 +28,15 @@ class GlowingObsidian extends Solid{
protected $id = self::GLOWING_OBSIDIAN;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Glowing Obsidian";
}
public function getLightLevel(){
public function getLightLevel() : int{
return 12;
}

View File

@ -29,15 +29,15 @@ class GlowingRedstoneOre extends RedstoneOre{
protected $id = self::GLOWING_REDSTONE_ORE;
public function getName(){
public function getName() : string{
return "Glowing Redstone Ore";
}
public function getLightLevel(){
public function getLightLevel() : int{
return 9;
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_SCHEDULED or $type === Level::BLOCK_UPDATE_RANDOM){
$this->getLevel()->setBlock($this, Block::get(Block::REDSTONE_ORE, $this->meta), false, false);

View File

@ -30,23 +30,23 @@ class Glowstone extends Transparent{
protected $id = self::GLOWSTONE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Glowstone";
}
public function getHardness(){
public function getHardness() : float{
return 0.3;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getLightLevel(){
public function getLightLevel() : int{
return 15;
}

View File

@ -30,19 +30,19 @@ class Gold extends Solid{
protected $id = self::GOLD_BLOCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Gold Block";
}
public function getHardness(){
public function getHardness() : float{
return 3;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}

View File

@ -30,19 +30,19 @@ class GoldOre extends Solid{
protected $id = self::GOLD_ORE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Gold Ore";
}
public function getHardness(){
public function getHardness() : float{
return 3;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}

View File

@ -36,19 +36,19 @@ class Grass extends Solid{
protected $id = self::GRASS;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Grass";
}
public function getHardness(){
public function getHardness() : float{
return 0.6;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_SHOVEL;
}
@ -58,7 +58,7 @@ class Grass extends Solid{
];
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_RANDOM){
$lightAbove = $this->level->getFullLightAt($this->x, $this->y + 1, $this->z);
if($lightAbove < 4 and Block::$lightFilter[$this->level->getBlockIdAt($this->x, $this->y + 1, $this->z)] >= 3){ //2 plus 1 standard filter amount
@ -97,7 +97,7 @@ class Grass extends Solid{
return false;
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
if($item->getId() === Item::DYE and $item->getDamage() === 0x0F){
$item->count--;
TallGrassObject::growGrass($this->getLevel(), $this, new Random(mt_rand()), 8, 2);

View File

@ -31,15 +31,15 @@ class GrassPath extends Transparent{
protected $id = self::GRASS_PATH;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Grass Path";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_SHOVEL;
}
@ -54,7 +54,7 @@ class GrassPath extends Transparent{
);
}
public function getHardness(){
public function getHardness() : float{
return 0.6;
}

View File

@ -30,19 +30,19 @@ class Gravel extends Fallable{
protected $id = self::GRAVEL;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Gravel";
}
public function getHardness(){
public function getHardness() : float{
return 0.6;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_SHOVEL;
}

View File

@ -29,19 +29,19 @@ class HardenedClay extends Solid{
protected $id = self::HARDENED_CLAY;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Hardened Clay";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getHardness(){
public function getHardness() : float{
return 1.25;
}
}

View File

@ -30,19 +30,19 @@ class HayBale extends Solid{
protected $id = self::HAY_BALE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Hay Bale";
}
public function getHardness(){
public function getHardness() : float{
return 0.5;
}
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{
$faces = [
0 => 0,
1 => 0,

View File

@ -31,15 +31,15 @@ class Ice extends Transparent{
protected $id = self::ICE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Ice";
}
public function getHardness(){
public function getHardness() : float{
return 0.5;
}
@ -47,17 +47,17 @@ class Ice extends Transparent{
return 2;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function onBreak(Item $item){
public function onBreak(Item $item) : bool{
$this->getLevel()->setBlock($this, new Water(), true);
return true;
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_RANDOM){
if($this->level->getHighestAdjacentBlockLight($this->x, $this->y, $this->z) >= 12){
$this->level->useBreakOn($this);

View File

@ -30,19 +30,19 @@ class Iron extends Solid{
protected $id = self::IRON_BLOCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Iron Block";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getHardness(){
public function getHardness() : float{
return 5;
}

View File

@ -30,19 +30,19 @@ class IronBars extends Thin{
protected $id = self::IRON_BARS;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Iron Bars";
}
public function getHardness(){
public function getHardness() : float{
return 5;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}

View File

@ -30,19 +30,19 @@ class IronDoor extends Door{
protected $id = self::IRON_DOOR_BLOCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Iron Door Block";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getHardness(){
public function getHardness() : float{
return 5;
}

View File

@ -30,19 +30,19 @@ class IronOre extends Solid{
protected $id = self::IRON_ORE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Iron Ore";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getHardness(){
public function getHardness() : float{
return 3;
}

View File

@ -29,15 +29,15 @@ class IronTrapdoor extends Trapdoor{
protected $id = self::IRON_TRAPDOOR;
public function getName(){
public function getName() : string{
return "Iron Trapdoor";
}
public function getHardness(){
public function getHardness() : float{
return 5;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
}

View File

@ -35,15 +35,15 @@ use pocketmine\tile\Tile;
class ItemFrame extends Flowable{
protected $id = Block::ITEM_FRAME_BLOCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Item Frame";
}
public function onActivate(Item $item, Player $player = null){
public function onActivate(Item $item, Player $player = null) : bool{
$tile = $this->level->getTile($this);
if(!($tile instanceof TileItemFrame)){
$nbt = new CompoundTag("", [
@ -74,7 +74,7 @@ class ItemFrame extends Flowable{
return true;
}
public function onBreak(Item $item){
public function onBreak(Item $item) : bool{
$tile = $this->level->getTile($this);
if($tile instanceof TileItemFrame){
//TODO: add events
@ -85,7 +85,7 @@ class ItemFrame extends Flowable{
return parent::onBreak($item);
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
$sides = [
0 => 4,
@ -101,7 +101,7 @@ class ItemFrame extends Flowable{
return false;
}
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{
if($face === 0 or $face === 1){
return false;
}

View File

@ -34,23 +34,23 @@ class Ladder extends Transparent{
protected $id = self::LADDER;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Ladder";
}
public function hasEntityCollision(){
public function hasEntityCollision() : bool{
return true;
}
public function isSolid(){
public function isSolid() : bool{
return false;
}
public function getHardness(){
public function getHardness() : float{
return 0.4;
}
@ -109,7 +109,7 @@ class Ladder extends Transparent{
}
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{
if($target->isTransparent() === false){
$faces = [
2 => 2,
@ -128,7 +128,7 @@ class Ladder extends Transparent{
return false;
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
$sides = [
2 => 3,
@ -145,7 +145,7 @@ class Ladder extends Transparent{
return false;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_AXE;
}

View File

@ -30,19 +30,19 @@ class Lapis extends Solid{
protected $id = self::LAPIS_BLOCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Lapis Lazuli Block";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getHardness(){
public function getHardness() : float{
return 3;
}

View File

@ -30,19 +30,19 @@ class LapisOre extends Solid{
protected $id = self::LAPIS_ORE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 3;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getName(){
public function getName() : string{
return "Lapis Lazuli Ore";
}

View File

@ -35,15 +35,15 @@ class Lava extends Liquid{
protected $id = self::FLOWING_LAVA;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getLightLevel(){
public function getLightLevel() : int{
return 15;
}
public function getName(){
public function getName() : string{
return "Lava";
}
@ -62,7 +62,7 @@ class Lava extends Liquid{
$entity->resetFallDistance();
}
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{
$ret = $this->getLevel()->setBlock($this, $this, true, false);
$this->getLevel()->scheduleDelayedBlockUpdate($this, $this->tickRate());

View File

@ -41,19 +41,19 @@ class Leaves extends Transparent{
protected $id = self::LEAVES;
protected $woodType = self::WOOD;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 0.2;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_SHEARS;
}
public function getName(){
public function getName() : string{
static $names = [
self::OAK => "Oak Leaves",
self::SPRUCE => "Spruce Leaves",
@ -132,7 +132,7 @@ class Leaves extends Transparent{
return false;
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if(($this->meta & 0b00001100) === 0){
$this->meta |= 0x08;
@ -159,9 +159,9 @@ class Leaves extends Transparent{
return false;
}
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{
$this->meta |= 0x04;
$this->getLevel()->setBlock($this, $this, true);
return $this->getLevel()->setBlock($this, $this, true);
}
public function getDrops(Item $item){

View File

@ -30,7 +30,7 @@ class Leaves2 extends Leaves{
protected $id = self::LEAVES2;
protected $woodType = self::WOOD2;
public function getName(){
public function getName() : string{
static $names = [
self::ACACIA => "Acacia Leaves",
self::DARK_OAK => "Dark Oak Leaves",

View File

@ -27,11 +27,11 @@ class Lever extends Flowable{
protected $id = self::LEVER;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Lever";
}
}

View File

@ -33,19 +33,19 @@ abstract class Liquid extends Transparent{
/** @var Vector3 */
private $temporalVector = null;
public function hasEntityCollision(){
public function hasEntityCollision() : bool{
return true;
}
public function isBreakable(Item $item){
public function isBreakable(Item $item) : bool{
return false;
}
public function canBeReplaced(){
public function canBeReplaced() : bool{
return true;
}
public function isSolid(){
public function isSolid() : bool{
return false;
}
@ -188,7 +188,7 @@ abstract class Liquid extends Transparent{
return 0;
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
$this->checkForHarden();
$this->getLevel()->scheduleDelayedBlockUpdate($this, $this->tickRate());
@ -358,7 +358,7 @@ abstract class Liquid extends Transparent{
return $cost;
}
public function getHardness(){
public function getHardness() : float{
return 100;
}

View File

@ -27,11 +27,11 @@ class LitPumpkin extends Pumpkin{
protected $id = self::LIT_PUMPKIN;
public function getLightLevel(){
public function getLightLevel() : int{
return 15;
}
public function getName(){
public function getName() : string{
return "Jack o'Lantern";
}
}

View File

@ -27,11 +27,11 @@ class LitRedstoneLamp extends RedstoneLamp{
protected $id = self::LIT_REDSTONE_LAMP;
public function getName(){
public function getName() : string{
return "Lit Redstone Lamp";
}
public function getLightLevel(){
public function getLightLevel() : int{
return 15;
}
}

View File

@ -30,19 +30,19 @@ class Melon extends Transparent{
protected $id = self::MELON_BLOCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Melon Block";
}
public function getHardness(){
public function getHardness() : float{
return 1;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_AXE;
}

View File

@ -33,15 +33,15 @@ class MelonStem extends Crops{
protected $id = self::MELON_STEM;
public function getName(){
public function getName() : string{
return "Melon Stem";
}
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(Vector3::SIDE_DOWN)->getId() !== Block::FARMLAND){
$this->getLevel()->useBreakOn($this);

View File

@ -30,19 +30,19 @@ class MonsterSpawner extends Solid{
protected $id = self::MONSTER_SPAWNER;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 5;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getName(){
public function getName() : string{
return "Monster Spawner";
}

View File

@ -30,19 +30,19 @@ class MossyCobblestone extends Solid{
protected $id = self::MOSSY_COBBLESTONE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Moss Stone";
}
public function getHardness(){
public function getHardness() : float{
return 2;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}

View File

@ -34,19 +34,19 @@ class Mycelium extends Solid{
protected $id = self::MYCELIUM;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Mycelium";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_SHOVEL;
}
public function getHardness(){
public function getHardness() : float{
return 0.6;
}
@ -56,7 +56,7 @@ class Mycelium extends Solid{
];
}
public function onUpdate($type){
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_RANDOM){
//TODO: light levels
$x = mt_rand($this->x - 1, $this->x + 1);

View File

@ -30,19 +30,19 @@ class NetherBrick extends Solid{
protected $id = self::NETHER_BRICK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getName(){
public function getName() : string{
return "Nether Bricks";
}
public function getHardness(){
public function getHardness() : float{
return 2;
}

View File

@ -29,19 +29,19 @@ class NetherBrickFence extends Transparent{
protected $id = self::NETHER_BRICK_FENCE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 2;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getName(){
public function getName() : string{
return "Nether Brick Fence";
}

View File

@ -29,19 +29,19 @@ class NetherBrickStairs extends Stair{
protected $id = self::NETHER_BRICK_STAIRS;
public function getName(){
public function getName() : string{
return "Nether Brick Stairs";
}
public function getHardness(){
public function getHardness() : float{
return 2;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}

View File

@ -29,11 +29,11 @@ use pocketmine\item\Tool;
class NetherReactor extends Solid{
protected $id = Block::NETHER_REACTOR;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
static $prefixes = [
"",
"Active ",
@ -42,11 +42,11 @@ class NetherReactor extends Solid{
return ($prefixes[$this->meta] ?? "") . "Nether Reactor Core";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getHardness(){
public function getHardness() : float{
return 3;
}

View File

@ -33,11 +33,11 @@ use pocketmine\Player;
class NetherWartPlant extends Flowable{
protected $id = Block::NETHER_WART_PLANT;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
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{
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() === Block::SOUL_SAND){
$this->getLevel()->setBlock($block, $this, false, true);
@ -48,7 +48,7 @@ class NetherWartPlant extends Flowable{
return false;
}
public function onUpdate($type){
public function onUpdate(int $type){
switch($type){
case Level::BLOCK_UPDATE_RANDOM:
if($this->meta < 3 and mt_rand(0, 10) === 0){ //Still growing

View File

@ -30,19 +30,19 @@ class Netherrack extends Solid{
protected $id = self::NETHERRACK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Netherrack";
}
public function getHardness(){
public function getHardness() : float{
return 0.4;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}

View File

@ -27,11 +27,11 @@ class NoteBlock extends Solid{
protected $id = self::NOTE_BLOCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Note Block";
}

View File

@ -30,19 +30,19 @@ class Obsidian extends Solid{
protected $id = self::OBSIDIAN;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Obsidian";
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}
public function getHardness(){
public function getHardness() : float{
return 35;
}

View File

@ -29,19 +29,19 @@ class PackedIce extends Solid{
protected $id = self::PACKED_ICE;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Packed Ice";
}
public function getHardness(){
public function getHardness() : float{
return 0.5;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_PICKAXE;
}

View File

@ -35,19 +35,19 @@ class Planks extends Solid{
protected $id = self::WOODEN_PLANKS;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getHardness(){
public function getHardness() : float{
return 2;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_AXE;
}
public function getName(){
public function getName() : string{
static $names = [
self::OAK => "Oak Wood Planks",
self::SPRUCE => "Spruce Wood Planks",

View File

@ -29,19 +29,19 @@ class Podzol extends Solid{
protected $id = self::PODZOL;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getToolType(){
public function getToolType() : int{
return Tool::TYPE_SHOVEL;
}
public function getName(){
public function getName() : string{
return "Podzol";
}
public function getHardness(){
public function getHardness() : float{
return 2.5;
}
}

View File

@ -29,11 +29,11 @@ class Potato extends Crops{
protected $id = self::POTATO_BLOCK;
public function __construct($meta = 0){
public function __construct(int $meta = 0){
$this->meta = $meta;
}
public function getName(){
public function getName() : string{
return "Potato Block";
}

Some files were not shown because too many files have changed in this diff Show More