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; protected $id = self::ACTIVATOR_RAIL;
public function getName(){ public function getName() : string{
return "Activator Rail"; return "Activator Rail";
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -375,7 +375,7 @@ class Block extends Position implements BlockIds, Metadatable{
* *
* @return Block * @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{ try{
$block = self::$fullList[($id << 4) | $meta]; $block = self::$fullList[($id << 4) | $meta];
if($block !== null){ if($block !== null){
@ -425,14 +425,14 @@ class Block extends Position implements BlockIds, Metadatable{
/** /**
* @return string * @return string
*/ */
public function getName(){ public function getName() : string{
return $this->fallbackName; return $this->fallbackName;
} }
/** /**
* @return int * @return int
*/ */
final public function getId(){ final public function getId() : int{
return $this->id; return $this->id;
} }
@ -449,32 +449,32 @@ class Block extends Position implements BlockIds, Metadatable{
/** /**
* @return int * @return int
*/ */
final public function getDamage(){ final public function getDamage() : int{
return $this->meta; return $this->meta;
} }
/** /**
* @param int $meta * @param int $meta
*/ */
final public function setDamage($meta){ final public function setDamage(int $meta){
$this->meta = $meta & 0x0f; $this->meta = $meta & 0x0f;
} }
/** /**
* Places the Block, using block space and block target, and side. Returns if the block has been placed. * Places the Block, using block space and block target, and side. Returns if the block has been placed.
* *
* @param Item $item * @param Item $item
* @param Block $block * @param Block $block
* @param Block $target * @param Block $target
* @param int $face * @param int $face
* @param float $fx * @param float $fx
* @param float $fy * @param float $fy
* @param float $fz * @param float $fz
* @param Player $player = null * @param Player|null $player
* *
* @return bool * @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); return $this->getLevel()->setBlock($this, $this, true, true);
} }
@ -485,7 +485,7 @@ class Block extends Position implements BlockIds, Metadatable{
* *
* @return bool * @return bool
*/ */
public function isBreakable(Item $item){ public function isBreakable(Item $item) : bool{
return true; return true;
} }
@ -494,9 +494,9 @@ class Block extends Position implements BlockIds, Metadatable{
* *
* @param Item $item * @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); return $this->getLevel()->setBlock($this, new Air(), true, true);
} }
@ -505,56 +505,56 @@ class Block extends Position implements BlockIds, Metadatable{
* *
* @param int $type * @param int $type
* *
* @return int|bool * @return bool|int
*/ */
public function onUpdate($type){ public function onUpdate(int $type){
return false; return false;
} }
/** /**
* Do actions when activated by Item. Returns if it has done anything * Do actions when activated by Item. Returns if it has done anything
* *
* @param Item $item * @param Item $item
* @param Player $player * @param Player|null $player
* *
* @return bool * @return bool
*/ */
public function onActivate(Item $item, Player $player = null){ public function onActivate(Item $item, Player $player = null) : bool{
return false; return false;
} }
/** /**
* @return float * @return float
*/ */
public function getHardness(){ public function getHardness() : float{
return 10; return 10;
} }
/** /**
* @return float * @return float
*/ */
public function getResistance(){ public function getResistance() : float{
return $this->getHardness() * 5; return $this->getHardness() * 5;
} }
/** /**
* @return int * @return int
*/ */
public function getToolType(){ public function getToolType() : int{
return Tool::TYPE_NONE; return Tool::TYPE_NONE;
} }
/** /**
* @return float * @return float
*/ */
public function getFrictionFactor(){ public function getFrictionFactor() : float{
return 0.6; return 0.6;
} }
/** /**
* @return int 0-15 * @return int 0-15
*/ */
public function getLightLevel(){ public function getLightLevel() : int{
return 0; return 0;
} }
@ -583,45 +583,43 @@ class Block extends Position implements BlockIds, Metadatable{
/** /**
* AKA: Block->isPlaceable * AKA: Block->isPlaceable
*
* @return bool * @return bool
*/ */
public function canBePlaced(){ public function canBePlaced() : bool{
return true; return true;
} }
/** /**
* @return bool * @return bool
*/ */
public function canBeReplaced(){ public function canBeReplaced() : bool{
return false; return false;
} }
/** /**
* @return bool * @return bool
*/ */
public function isTransparent(){ public function isTransparent() : bool{
return false; return false;
} }
public function isSolid(){ public function isSolid() : bool{
return true; return true;
} }
/** /**
* AKA: Block->isFlowable * AKA: Block->isFlowable
*
* @return bool * @return bool
*/ */
public function canBeFlowedInto(){ public function canBeFlowedInto() : bool{
return false; return false;
} }
public function hasEntityCollision(){ public function hasEntityCollision() : bool{
return false; return false;
} }
public function canPassThrough(){ public function canPassThrough() : bool{
return false; return false;
} }
@ -671,7 +669,7 @@ class Block extends Position implements BlockIds, Metadatable{
* *
* @return float * @return float
*/ */
public function getBreakTime(Item $item){ public function getBreakTime(Item $item) : float{
$base = $this->getHardness() * 1.5; $base = $this->getHardness() * 1.5;
if($this->canBeBrokenWith($item)){ if($this->canBeBrokenWith($item)){
if($this->getToolType() === Tool::TYPE_SHEARS and $item->isShears()){ if($this->getToolType() === Tool::TYPE_SHEARS and $item->isShears()){
@ -710,7 +708,7 @@ class Block extends Position implements BlockIds, Metadatable{
return $base; return $base;
} }
public function canBeBrokenWith(Item $item){ public function canBeBrokenWith(Item $item) : bool{
return $this->getHardness() !== -1; return $this->getHardness() !== -1;
} }
@ -752,7 +750,7 @@ class Block extends Position implements BlockIds, Metadatable{
* *
* @return bool * @return bool
*/ */
public function collidesWithBB(AxisAlignedBB $bb){ public function collidesWithBB(AxisAlignedBB $bb) : bool{
$bb2 = $this->getBoundingBox(); $bb2 = $this->getBoundingBox();
return $bb2 !== null and $bb->intersectsWith($bb2); return $bb2 !== null and $bb->intersectsWith($bb2);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -29,15 +29,15 @@ class GlowingRedstoneOre extends RedstoneOre{
protected $id = self::GLOWING_REDSTONE_ORE; protected $id = self::GLOWING_REDSTONE_ORE;
public function getName(){ public function getName() : string{
return "Glowing Redstone Ore"; return "Glowing Redstone Ore";
} }
public function getLightLevel(){ public function getLightLevel() : int{
return 9; return 9;
} }
public function onUpdate($type){ public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_SCHEDULED or $type === Level::BLOCK_UPDATE_RANDOM){ 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); $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; protected $id = self::GLOWSTONE;
public function __construct($meta = 0){ public function __construct(int $meta = 0){
$this->meta = $meta; $this->meta = $meta;
} }
public function getName(){ public function getName() : string{
return "Glowstone"; return "Glowstone";
} }
public function getHardness(){ public function getHardness() : float{
return 0.3; return 0.3;
} }
public function getToolType(){ public function getToolType() : int{
return Tool::TYPE_PICKAXE; return Tool::TYPE_PICKAXE;
} }
public function getLightLevel(){ public function getLightLevel() : int{
return 15; return 15;
} }

View File

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

View File

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

View File

@ -36,19 +36,19 @@ class Grass extends Solid{
protected $id = self::GRASS; protected $id = self::GRASS;
public function __construct($meta = 0){ public function __construct(int $meta = 0){
$this->meta = $meta; $this->meta = $meta;
} }
public function getName(){ public function getName() : string{
return "Grass"; return "Grass";
} }
public function getHardness(){ public function getHardness() : float{
return 0.6; return 0.6;
} }
public function getToolType(){ public function getToolType() : int{
return Tool::TYPE_SHOVEL; 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){ if($type === Level::BLOCK_UPDATE_RANDOM){
$lightAbove = $this->level->getFullLightAt($this->x, $this->y + 1, $this->z); $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 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; 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){ if($item->getId() === Item::DYE and $item->getDamage() === 0x0F){
$item->count--; $item->count--;
TallGrassObject::growGrass($this->getLevel(), $this, new Random(mt_rand()), 8, 2); 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; protected $id = self::GRASS_PATH;
public function __construct($meta = 0){ public function __construct(int $meta = 0){
$this->meta = $meta; $this->meta = $meta;
} }
public function getName(){ public function getName() : string{
return "Grass Path"; return "Grass Path";
} }
public function getToolType(){ public function getToolType() : int{
return Tool::TYPE_SHOVEL; return Tool::TYPE_SHOVEL;
} }
@ -54,7 +54,7 @@ class GrassPath extends Transparent{
); );
} }
public function getHardness(){ public function getHardness() : float{
return 0.6; return 0.6;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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