diff --git a/src/pocketmine/block/Anvil.php b/src/pocketmine/block/Anvil.php index e89c679164..3a8faca911 100644 --- a/src/pocketmine/block/Anvil.php +++ b/src/pocketmine/block/Anvil.php @@ -79,13 +79,13 @@ class Anvil extends Fallable{ return $this->getLevel()->setBlock($block, $this, true, true); } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ - [$this->id, $this->meta & 0x0c, 1], + Item::get($this->getItemId(), $this->getDamage() & 0x0c, 1), ]; - }else{ - return []; } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/Bed.php b/src/pocketmine/block/Bed.php index 0bec31d3d4..8016b22aef 100644 --- a/src/pocketmine/block/Bed.php +++ b/src/pocketmine/block/Bed.php @@ -43,6 +43,8 @@ class Bed extends Transparent{ protected $id = self::BED_BLOCK; + protected $itemId = Item::BED; + public function __construct(int $meta = 0){ $this->meta = $meta; } @@ -212,21 +214,21 @@ class Bed extends Transparent{ return true; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($this->isHeadPart()){ $tile = $this->getLevel()->getTile($this); if($tile instanceof TileBed){ return [ - [Item::BED, $tile->getColor(), 1] + Item::get($this->getItemId(), $tile->getColor(), 1) ]; }else{ return [ - [Item::BED, 14, 1] //Red + Item::get($this->getItemId(), 14, 1) //Red ]; } - }else{ - return []; } + + return []; } } diff --git a/src/pocketmine/block/Beetroot.php b/src/pocketmine/block/Beetroot.php index b1de667e36..b52cee56d2 100644 --- a/src/pocketmine/block/Beetroot.php +++ b/src/pocketmine/block/Beetroot.php @@ -37,15 +37,16 @@ class Beetroot extends Crops{ return "Beetroot Block"; } - public function getDrops(Item $item){ - $drops = []; + public function getDrops(Item $item) : array{ if($this->meta >= 0x07){ - $drops[] = [Item::BEETROOT, 0, 1]; - $drops[] = [Item::BEETROOT_SEEDS, 0, mt_rand(0, 3)]; - }else{ - $drops[] = [Item::BEETROOT_SEEDS, 0, 1]; + return [ + Item::get(Item::BEETROOT, 0, 1), + Item::get(Item::BEETROOT_SEEDS, 0, mt_rand(0, 3)) + ]; } - return $drops; + return [ + Item::get(Item::BEETROOT_SEEDS, 0, 1) + ]; } } \ No newline at end of file diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index 027955ffc1..2b94e335f8 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -654,11 +654,11 @@ class Block extends Position implements BlockIds, Metadatable{ * * @param Item $item * - * @return array + * @return Item[] */ - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [$this->getItemId(), $this->getDamage(), 1], + Item::get($this->getItemId(), $this->getDamage(), 1), ]; } diff --git a/src/pocketmine/block/Bookshelf.php b/src/pocketmine/block/Bookshelf.php index 9a12f77970..690877d43c 100644 --- a/src/pocketmine/block/Bookshelf.php +++ b/src/pocketmine/block/Bookshelf.php @@ -46,9 +46,9 @@ class Bookshelf extends Solid{ return Tool::TYPE_AXE; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [Item::BOOK, 0, 3] + Item::get(Item::BOOK, 0, 3) ]; } diff --git a/src/pocketmine/block/Bricks.php b/src/pocketmine/block/Bricks.php index ff90619eb7..345ffb2c9c 100644 --- a/src/pocketmine/block/Bricks.php +++ b/src/pocketmine/block/Bricks.php @@ -50,13 +50,11 @@ class Bricks extends Solid{ return "Bricks"; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_WOODEN){ - return [ - [Item::BRICK_BLOCK, 0, 1], - ]; - }else{ - return []; + return parent::getDrops($item); } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/BurningFurnace.php b/src/pocketmine/block/BurningFurnace.php index ddc2b91f52..c4ac26b73b 100644 --- a/src/pocketmine/block/BurningFurnace.php +++ b/src/pocketmine/block/BurningFurnace.php @@ -118,12 +118,13 @@ class BurningFurnace extends Solid{ return true; } - public function getDrops(Item $item){ - $drops = []; + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_WOODEN){ - $drops[] = [Item::FURNACE, 0, 1]; + return [ + Item::get($this->getItemId(), 0, 1) + ]; } - return $drops; + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/Cactus.php b/src/pocketmine/block/Cactus.php index 4903302379..a04f376652 100644 --- a/src/pocketmine/block/Cactus.php +++ b/src/pocketmine/block/Cactus.php @@ -125,9 +125,9 @@ class Cactus extends Transparent{ return false; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [$this->id, 0, 1], + Item::get($this->getItemId(), 0, 1) ]; } } \ No newline at end of file diff --git a/src/pocketmine/block/Cake.php b/src/pocketmine/block/Cake.php index 40f254e2b4..64ba440df6 100644 --- a/src/pocketmine/block/Cake.php +++ b/src/pocketmine/block/Cake.php @@ -85,7 +85,7 @@ class Cake extends Transparent implements FoodSource{ return false; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return []; } diff --git a/src/pocketmine/block/Carrot.php b/src/pocketmine/block/Carrot.php index a9acbc11c4..e1014775b7 100644 --- a/src/pocketmine/block/Carrot.php +++ b/src/pocketmine/block/Carrot.php @@ -37,14 +37,9 @@ class Carrot extends Crops{ return "Carrot Block"; } - public function getDrops(Item $item){ - $drops = []; - if($this->meta >= 0x07){ - $drops[] = [Item::CARROT, 0, mt_rand(1, 4)]; - }else{ - $drops[] = [Item::CARROT, 0, 1]; - } - - return $drops; + public function getDrops(Item $item) : array{ + return [ + Item::get(Item::CARROT, 0, $this->meta >= 0x07 ? mt_rand(1, 4) : 1) + ]; } } \ No newline at end of file diff --git a/src/pocketmine/block/Chest.php b/src/pocketmine/block/Chest.php index b688647177..cf92156fe4 100644 --- a/src/pocketmine/block/Chest.php +++ b/src/pocketmine/block/Chest.php @@ -169,9 +169,9 @@ class Chest extends Transparent{ return true; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [$this->id, 0, 1], + Item::get($this->getItemId(), 0, 1) ]; } diff --git a/src/pocketmine/block/Clay.php b/src/pocketmine/block/Clay.php index 3afb17a5fb..fac2194fa0 100644 --- a/src/pocketmine/block/Clay.php +++ b/src/pocketmine/block/Clay.php @@ -46,9 +46,9 @@ class Clay extends Solid{ return "Clay Block"; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [Item::CLAY, 0, 4], + Item::get(Item::CLAY_BALL, 0, 4) ]; } } \ No newline at end of file diff --git a/src/pocketmine/block/Coal.php b/src/pocketmine/block/Coal.php index 46b50dc178..423a208502 100644 --- a/src/pocketmine/block/Coal.php +++ b/src/pocketmine/block/Coal.php @@ -46,14 +46,12 @@ class Coal extends Solid{ return "Coal Block"; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_WOODEN){ - return [ - [Item::COAL_BLOCK, 0, 1], - ]; - }else{ - return []; + return parent::getDrops($item); } + + return []; } public function getFuelTime() : int{ diff --git a/src/pocketmine/block/CoalOre.php b/src/pocketmine/block/CoalOre.php index 2ba2b6209a..de4aff9558 100644 --- a/src/pocketmine/block/CoalOre.php +++ b/src/pocketmine/block/CoalOre.php @@ -46,14 +46,14 @@ class CoalOre extends Solid{ return "Coal Ore"; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ - [Item::COAL, 0, 1], + Item::get(Item::COAL, 0, 1) ]; - }else{ - return []; } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/Cobblestone.php b/src/pocketmine/block/Cobblestone.php index df6d0ae647..68a1c26b73 100644 --- a/src/pocketmine/block/Cobblestone.php +++ b/src/pocketmine/block/Cobblestone.php @@ -46,13 +46,11 @@ class Cobblestone extends Solid{ return 2; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_WOODEN){ - return [ - [Item::COBBLESTONE, 0, 1], - ]; - }else{ - return []; + return parent::getDrops($item); } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/Cobweb.php b/src/pocketmine/block/Cobweb.php index 70c2163fb0..92aa8f82a8 100644 --- a/src/pocketmine/block/Cobweb.php +++ b/src/pocketmine/block/Cobweb.php @@ -55,7 +55,7 @@ class Cobweb extends Flowable{ $entity->resetFallDistance(); } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ //TODO: correct drops return []; } diff --git a/src/pocketmine/block/CraftingTable.php b/src/pocketmine/block/CraftingTable.php index 797ef4ee45..2c688160cb 100644 --- a/src/pocketmine/block/CraftingTable.php +++ b/src/pocketmine/block/CraftingTable.php @@ -55,12 +55,6 @@ class CraftingTable extends Solid{ return true; } - public function getDrops(Item $item){ - return [ - [$this->id, 0, 1], - ]; - } - public function getFuelTime() : int{ return 300; } diff --git a/src/pocketmine/block/Diamond.php b/src/pocketmine/block/Diamond.php index baedad53f1..7420beebb3 100644 --- a/src/pocketmine/block/Diamond.php +++ b/src/pocketmine/block/Diamond.php @@ -46,13 +46,11 @@ class Diamond extends Solid{ return Tool::TYPE_PICKAXE; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_IRON){ - return [ - [Item::DIAMOND_BLOCK, 0, 1], - ]; - }else{ - return []; + return parent::getDrops($item); } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/DiamondOre.php b/src/pocketmine/block/DiamondOre.php index f9e2992b43..3fef5ad2ee 100644 --- a/src/pocketmine/block/DiamondOre.php +++ b/src/pocketmine/block/DiamondOre.php @@ -46,13 +46,13 @@ class DiamondOre extends Solid{ return Tool::TYPE_PICKAXE; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_IRON){ return [ - [Item::DIAMOND, 0, 1], + Item::get(Item::DIAMOND, 0, 1) ]; - }else{ - return []; } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/DoublePlant.php b/src/pocketmine/block/DoublePlant.php index 2287da7968..b66833781d 100644 --- a/src/pocketmine/block/DoublePlant.php +++ b/src/pocketmine/block/DoublePlant.php @@ -104,19 +104,19 @@ class DoublePlant extends Flowable{ return false; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if(!$item->isShears() and ($this->meta === 2 or $this->meta === 3)){ //grass or fern if(mt_rand(0, 24) === 0){ return [ - [Item::SEEDS, 0, 1] + Item::get(Item::SEEDS, 0, 1) ]; - }else{ - return []; } + + return []; } return [ - [$this->id, $this->meta & 0x07, 1] + Item::get($this->getItemId(), $this->getDamage() & 0x07, 1) ]; } } \ No newline at end of file diff --git a/src/pocketmine/block/DoubleStoneSlab.php b/src/pocketmine/block/DoubleStoneSlab.php index b2c4e456db..8970f6b591 100644 --- a/src/pocketmine/block/DoubleStoneSlab.php +++ b/src/pocketmine/block/DoubleStoneSlab.php @@ -56,14 +56,14 @@ class DoubleStoneSlab extends Solid{ return "Double " . $names[$this->meta & 0x07] . " Slab"; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ - [Item::STONE_SLAB, $this->meta & 0x07, 2], + Item::get(Item::STONE_SLAB, $this->getDamage() & 0x07, 2), ]; - }else{ - return []; } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/DoubleWoodenSlab.php b/src/pocketmine/block/DoubleWoodenSlab.php index a4f431b482..297f94d48a 100644 --- a/src/pocketmine/block/DoubleWoodenSlab.php +++ b/src/pocketmine/block/DoubleWoodenSlab.php @@ -54,9 +54,9 @@ class DoubleWoodenSlab extends Solid{ return "Double " . ($names[$this->meta & 0x07] ?? "") . " Wooden Slab"; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [Item::WOODEN_SLAB, $this->meta & 0x07, 2], + Item::get(Item::WOODEN_SLAB, $this->getDamage() & 0x07, 2) ]; } diff --git a/src/pocketmine/block/Emerald.php b/src/pocketmine/block/Emerald.php index 6cb9bd53e8..80c4ebf3d9 100644 --- a/src/pocketmine/block/Emerald.php +++ b/src/pocketmine/block/Emerald.php @@ -46,13 +46,11 @@ class Emerald extends Solid{ return "Emerald Block"; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_IRON){ - return [ - [Item::EMERALD_BLOCK, 0, 1], - ]; - }else{ - return []; + return parent::getDrops($item); } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/EmeraldOre.php b/src/pocketmine/block/EmeraldOre.php index 3ace4ec7fd..9468819e15 100644 --- a/src/pocketmine/block/EmeraldOre.php +++ b/src/pocketmine/block/EmeraldOre.php @@ -46,13 +46,13 @@ class EmeraldOre extends Solid{ return 3; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_IRON){ return [ - [Item::EMERALD, 0, 1], + Item::get(Item::EMERALD, 0, 1), ]; - }else{ - return []; } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/EnchantingTable.php b/src/pocketmine/block/EnchantingTable.php index d3f3c263c4..9cd1af2f16 100644 --- a/src/pocketmine/block/EnchantingTable.php +++ b/src/pocketmine/block/EnchantingTable.php @@ -90,13 +90,13 @@ class EnchantingTable extends Transparent{ return true; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ - [$this->id, 0, 1], + Item::get($this->getItemId(), 0, 1) ]; - }else{ - return []; } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/Farmland.php b/src/pocketmine/block/Farmland.php index 426fa8ae76..31d9ef6b5d 100644 --- a/src/pocketmine/block/Farmland.php +++ b/src/pocketmine/block/Farmland.php @@ -58,9 +58,9 @@ class Farmland extends Transparent{ ); } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [Item::DIRT, 0, 1], + Item::get(Item::DIRT, 0, 1) ]; } } \ No newline at end of file diff --git a/src/pocketmine/block/FenceGate.php b/src/pocketmine/block/FenceGate.php index 3153d19296..e417da24ab 100644 --- a/src/pocketmine/block/FenceGate.php +++ b/src/pocketmine/block/FenceGate.php @@ -75,9 +75,9 @@ class FenceGate extends Transparent{ return true; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [$this->id, 0, 1], + Item::get($this->getItemId(), 0, 1) ]; } diff --git a/src/pocketmine/block/Fire.php b/src/pocketmine/block/Fire.php index f7ceda0343..7568a9264d 100644 --- a/src/pocketmine/block/Fire.php +++ b/src/pocketmine/block/Fire.php @@ -75,7 +75,7 @@ class Fire extends Flowable{ } } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return []; } diff --git a/src/pocketmine/block/FlowerPot.php b/src/pocketmine/block/FlowerPot.php index 44dd69fd94..623b0d8d00 100644 --- a/src/pocketmine/block/FlowerPot.php +++ b/src/pocketmine/block/FlowerPot.php @@ -41,6 +41,7 @@ class FlowerPot extends Flowable{ const STATE_FULL = 1; protected $id = self::FLOWER_POT_BLOCK; + protected $itemId = Item::FLOWER_POT; public function __construct(int $meta = 0){ $this->meta = $meta; @@ -121,14 +122,17 @@ class FlowerPot extends Flowable{ return true; } - public function getDrops(Item $item){ - $items = [[Item::FLOWER_POT, 0, 1]]; + public function getDrops(Item $item) : array{ + $items = parent::getDrops($item); + $tile = $this->getLevel()->getTile($this); if($tile instanceof TileFlowerPot){ - if(($item = $tile->getItem())->getId() !== Item::AIR){ - $items[] = [$item->getId(), $item->getDamage(), 1]; + $item = $tile->getItem(); + if($item->getId() !== Item::AIR){ + $items[] = $item; } } + return $items; } diff --git a/src/pocketmine/block/Glass.php b/src/pocketmine/block/Glass.php index fe460f1d3f..5a0436da02 100644 --- a/src/pocketmine/block/Glass.php +++ b/src/pocketmine/block/Glass.php @@ -41,7 +41,7 @@ class Glass extends Transparent{ return 0.3; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/GlassPane.php b/src/pocketmine/block/GlassPane.php index f67faca64b..878beb2861 100644 --- a/src/pocketmine/block/GlassPane.php +++ b/src/pocketmine/block/GlassPane.php @@ -41,7 +41,7 @@ class GlassPane extends Thin{ return 0.3; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/GlazedTerracotta.php b/src/pocketmine/block/GlazedTerracotta.php index b2df2c0c86..d707c38e3a 100644 --- a/src/pocketmine/block/GlazedTerracotta.php +++ b/src/pocketmine/block/GlazedTerracotta.php @@ -52,13 +52,13 @@ class GlazedTerracotta extends Solid{ return $this->getLevel()->setBlock($block, $this, true, true); } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ - [$this->getId(), 0, 1], + Item::get($this->getItemId(), 0, 1) ]; - }else{ - return []; } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/Glowstone.php b/src/pocketmine/block/Glowstone.php index 8d850b6313..35ae6101ed 100644 --- a/src/pocketmine/block/Glowstone.php +++ b/src/pocketmine/block/Glowstone.php @@ -50,9 +50,9 @@ class Glowstone extends Transparent{ return 15; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [Item::GLOWSTONE_DUST, 0, mt_rand(2, 4)], + Item::get(Item::GLOWSTONE_DUST, 0, mt_rand(2, 4)) ]; } } \ No newline at end of file diff --git a/src/pocketmine/block/Gold.php b/src/pocketmine/block/Gold.php index e000d0526c..69a7bc286b 100644 --- a/src/pocketmine/block/Gold.php +++ b/src/pocketmine/block/Gold.php @@ -46,13 +46,11 @@ class Gold extends Solid{ return Tool::TYPE_PICKAXE; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_IRON){ - return [ - [Item::GOLD_BLOCK, 0, 1], - ]; - }else{ - return []; + return parent::getDrops($item); } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/GoldOre.php b/src/pocketmine/block/GoldOre.php index 59841d708e..e5807d0278 100644 --- a/src/pocketmine/block/GoldOre.php +++ b/src/pocketmine/block/GoldOre.php @@ -46,13 +46,11 @@ class GoldOre extends Solid{ return Tool::TYPE_PICKAXE; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_IRON){ - return [ - [Item::GOLD_ORE, 0, 1], - ]; - }else{ - return []; + return parent::getDrops($item); } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/Grass.php b/src/pocketmine/block/Grass.php index 97c80a7db8..204d4ea502 100644 --- a/src/pocketmine/block/Grass.php +++ b/src/pocketmine/block/Grass.php @@ -52,9 +52,9 @@ class Grass extends Solid{ return Tool::TYPE_SHOVEL; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [Item::DIRT, 0, 1], + Item::get(Item::DIRT, 0, 1), ]; } diff --git a/src/pocketmine/block/GrassPath.php b/src/pocketmine/block/GrassPath.php index 3d688c12a3..0fce7e0480 100644 --- a/src/pocketmine/block/GrassPath.php +++ b/src/pocketmine/block/GrassPath.php @@ -58,9 +58,9 @@ class GrassPath extends Transparent{ return 0.6; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [Item::DIRT, 0, 1], + Item::get(Item::DIRT, 0, 1) ]; } } \ No newline at end of file diff --git a/src/pocketmine/block/Gravel.php b/src/pocketmine/block/Gravel.php index 80b786738e..7fc70070c3 100644 --- a/src/pocketmine/block/Gravel.php +++ b/src/pocketmine/block/Gravel.php @@ -46,15 +46,15 @@ class Gravel extends Fallable{ return Tool::TYPE_SHOVEL; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if(mt_rand(1, 10) === 1){ return [ - [Item::FLINT, 0, 1], + Item::get(Item::FLINT, 0, 1) ]; } return [ - [Item::GRAVEL, 0, 1], + Item::get(Item::GRAVEL, 0, 1) ]; } diff --git a/src/pocketmine/block/HayBale.php b/src/pocketmine/block/HayBale.php index 652700c52c..fca892481b 100644 --- a/src/pocketmine/block/HayBale.php +++ b/src/pocketmine/block/HayBale.php @@ -58,9 +58,9 @@ class HayBale extends Solid{ return true; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [$this->id, 0, 1], + Item::get($this->getItemId(), 0, 1) ]; } diff --git a/src/pocketmine/block/Ice.php b/src/pocketmine/block/Ice.php index da1941d4db..3b65092099 100644 --- a/src/pocketmine/block/Ice.php +++ b/src/pocketmine/block/Ice.php @@ -68,7 +68,7 @@ class Ice extends Transparent{ return false; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/Iron.php b/src/pocketmine/block/Iron.php index 83a7c1b548..8ab234d5ee 100644 --- a/src/pocketmine/block/Iron.php +++ b/src/pocketmine/block/Iron.php @@ -46,13 +46,11 @@ class Iron extends Solid{ return 5; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_STONE){ - return [ - [Item::IRON_BLOCK, 0, 1], - ]; - }else{ - return []; + return parent::getDrops($item); } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/IronBars.php b/src/pocketmine/block/IronBars.php index d37aa545d5..2c8d1bbf02 100644 --- a/src/pocketmine/block/IronBars.php +++ b/src/pocketmine/block/IronBars.php @@ -46,14 +46,14 @@ class IronBars extends Thin{ return Tool::TYPE_PICKAXE; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ - [Item::IRON_BARS, 0, 1], + Item::get($this->getItemId(), 0, 1) ]; - }else{ - return []; } + + return []; } } diff --git a/src/pocketmine/block/IronDoor.php b/src/pocketmine/block/IronDoor.php index f2b38cb6a4..1c2d6322a9 100644 --- a/src/pocketmine/block/IronDoor.php +++ b/src/pocketmine/block/IronDoor.php @@ -30,6 +30,8 @@ class IronDoor extends Door{ protected $id = self::IRON_DOOR_BLOCK; + protected $itemId = Item::IRON_DOOR; + public function __construct(int $meta = 0){ $this->meta = $meta; } @@ -46,13 +48,11 @@ class IronDoor extends Door{ return 5; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_WOODEN){ - return [ - [Item::IRON_DOOR, 0, 1], - ]; - }else{ - return []; + return parent::getDrops($item); } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/IronOre.php b/src/pocketmine/block/IronOre.php index 7d2a433053..b0ab3bb469 100644 --- a/src/pocketmine/block/IronOre.php +++ b/src/pocketmine/block/IronOre.php @@ -46,13 +46,11 @@ class IronOre extends Solid{ return 3; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_STONE){ - return [ - [Item::IRON_ORE, 0, 1], - ]; - }else{ - return []; + return parent::getDrops($item); } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/ItemFrame.php b/src/pocketmine/block/ItemFrame.php index 97050a14eb..f57390616b 100644 --- a/src/pocketmine/block/ItemFrame.php +++ b/src/pocketmine/block/ItemFrame.php @@ -35,6 +35,8 @@ use pocketmine\tile\Tile; class ItemFrame extends Flowable{ protected $id = Block::ITEM_FRAME_BLOCK; + protected $itemId = Item::ITEM_FRAME; + public function __construct(int $meta = 0){ $this->meta = $meta; } @@ -137,9 +139,9 @@ class ItemFrame extends Flowable{ } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [Item::ITEM_FRAME, 0, 1] + Item::get($this->getItemId(), 0, 1) ]; } diff --git a/src/pocketmine/block/Ladder.php b/src/pocketmine/block/Ladder.php index 2b948bc65d..b73293fd6e 100644 --- a/src/pocketmine/block/Ladder.php +++ b/src/pocketmine/block/Ladder.php @@ -149,9 +149,9 @@ class Ladder extends Transparent{ return Tool::TYPE_AXE; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [$this->id, 0, 1], + Item::get($this->getItemId(), 0, 1) ]; } } \ No newline at end of file diff --git a/src/pocketmine/block/Lapis.php b/src/pocketmine/block/Lapis.php index 2924afe437..0931708c1a 100644 --- a/src/pocketmine/block/Lapis.php +++ b/src/pocketmine/block/Lapis.php @@ -46,14 +46,12 @@ class Lapis extends Solid{ return 3; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_STONE){ - return [ - [Item::LAPIS_BLOCK, 0, 1], - ]; - }else{ - return []; + return parent::getDrops($item); } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/LapisOre.php b/src/pocketmine/block/LapisOre.php index a8243ebffc..168e63cd11 100644 --- a/src/pocketmine/block/LapisOre.php +++ b/src/pocketmine/block/LapisOre.php @@ -46,14 +46,14 @@ class LapisOre extends Solid{ return "Lapis Lazuli Ore"; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_STONE){ return [ - [Item::DYE, 4, mt_rand(4, 8)], + Item::get(Item::DYE, 4, mt_rand(4, 8)) ]; - }else{ - return []; } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/Leaves.php b/src/pocketmine/block/Leaves.php index 8fb0deb831..4bf9185728 100644 --- a/src/pocketmine/block/Leaves.php +++ b/src/pocketmine/block/Leaves.php @@ -164,16 +164,19 @@ class Leaves extends Transparent{ return $this->getLevel()->setBlock($this, $this, true); } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ $drops = []; + + $variantMeta = $this->getDamage() & 0x03; + if($item->isShears()){ - $drops[] = [$this->id, $this->meta & 0x03, 1]; + $drops[] = Item::get($this->getItemId(), $variantMeta, 1); }else{ if(mt_rand(1, 20) === 1){ //Saplings - $drops[] = [Item::SAPLING, $this->meta & 0x03, 1]; + $drops[] = Item::get(Item::SAPLING, $variantMeta, 1); } - if(($this->meta & 0x03) === self::OAK and mt_rand(1, 200) === 1){ //Apples - $drops[] = [Item::APPLE, 0, 1]; + if($variantMeta === self::OAK and mt_rand(1, 200) === 1){ //Apples + $drops[] = Item::get(Item::APPLE, 0, 1); } } diff --git a/src/pocketmine/block/Leaves2.php b/src/pocketmine/block/Leaves2.php index b25668f873..e05ee91366 100644 --- a/src/pocketmine/block/Leaves2.php +++ b/src/pocketmine/block/Leaves2.php @@ -35,19 +35,22 @@ class Leaves2 extends Leaves{ self::ACACIA => "Acacia Leaves", self::DARK_OAK => "Dark Oak Leaves", ]; - return $names[$this->meta & 0x01]; + return $names[$this->meta & 0x03] ?? "Unknown"; } - public function getDrops(Item $item){ - $drops = []; + public function getDrops(Item $item) : array{ + $variantMeta = $this->getDamage() & 0x03; + if($item->isShears()){ - $drops[] = [$this->id, $this->meta & 0x01, 1]; - }else{ - if(mt_rand(1, 20) === 1){ //Saplings - $drops[] = [Item::SAPLING, ($this->meta & 0x01) + 4, 1]; - } + return [ + Item::get($this->getItemId(), $variantMeta, 1) + ]; + }elseif(mt_rand(1, 20) === 1){ //Saplings + return [ + Item::get(Item::SAPLING, $variantMeta + 4, 1) + ]; } - return $drops; + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/Liquid.php b/src/pocketmine/block/Liquid.php index 100e29bee0..a4cd8a23c9 100644 --- a/src/pocketmine/block/Liquid.php +++ b/src/pocketmine/block/Liquid.php @@ -446,7 +446,7 @@ abstract class Liquid extends Transparent{ return null; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/Melon.php b/src/pocketmine/block/Melon.php index 02e02cc31e..3a8a4a4dc9 100644 --- a/src/pocketmine/block/Melon.php +++ b/src/pocketmine/block/Melon.php @@ -46,9 +46,9 @@ class Melon extends Transparent{ return Tool::TYPE_AXE; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [Item::MELON_SLICE, 0, mt_rand(3, 7)], + Item::get(Item::MELON_SLICE, 0, mt_rand(3, 7)) ]; } } \ No newline at end of file diff --git a/src/pocketmine/block/MelonStem.php b/src/pocketmine/block/MelonStem.php index 4829e71d59..067582cbd2 100644 --- a/src/pocketmine/block/MelonStem.php +++ b/src/pocketmine/block/MelonStem.php @@ -82,9 +82,9 @@ class MelonStem extends Crops{ return false; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [Item::MELON_SEEDS, 0, mt_rand(0, 2)], + Item::get(Item::MELON_SEEDS, 0, mt_rand(0, 2)) ]; } } \ No newline at end of file diff --git a/src/pocketmine/block/MonsterSpawner.php b/src/pocketmine/block/MonsterSpawner.php index e22fec7a6f..86bc7687db 100644 --- a/src/pocketmine/block/MonsterSpawner.php +++ b/src/pocketmine/block/MonsterSpawner.php @@ -46,7 +46,7 @@ class MonsterSpawner extends Solid{ return "Monster Spawner"; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/MossyCobblestone.php b/src/pocketmine/block/MossyCobblestone.php index 569a4b6fbb..e6e0f95ba2 100644 --- a/src/pocketmine/block/MossyCobblestone.php +++ b/src/pocketmine/block/MossyCobblestone.php @@ -26,33 +26,11 @@ namespace pocketmine\block; use pocketmine\item\Item; use pocketmine\item\Tool; -class MossyCobblestone extends Solid{ +class MossyCobblestone extends Cobblestone{ protected $id = self::MOSSY_COBBLESTONE; - public function __construct(int $meta = 0){ - $this->meta = $meta; - } - public function getName() : string{ return "Moss Stone"; } - - public function getHardness() : float{ - return 2; - } - - public function getToolType() : int{ - return Tool::TYPE_PICKAXE; - } - - public function getDrops(Item $item){ - if($item->isPickaxe() >= Tool::TIER_WOODEN){ - return [ - [Item::MOSSY_COBBLESTONE, $this->meta, 1], - ]; - }else{ - return []; - } - } } \ No newline at end of file diff --git a/src/pocketmine/block/Mycelium.php b/src/pocketmine/block/Mycelium.php index 539eae09a3..90a41dd5d1 100644 --- a/src/pocketmine/block/Mycelium.php +++ b/src/pocketmine/block/Mycelium.php @@ -50,9 +50,9 @@ class Mycelium extends Solid{ return 0.6; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [Item::DIRT, 0, 1], + Item::get(Item::DIRT, 0, 1) ]; } diff --git a/src/pocketmine/block/NetherBrick.php b/src/pocketmine/block/NetherBrick.php index 9d15cd7c4c..b2380c829b 100644 --- a/src/pocketmine/block/NetherBrick.php +++ b/src/pocketmine/block/NetherBrick.php @@ -28,7 +28,7 @@ use pocketmine\item\Tool; class NetherBrick extends Solid{ - protected $id = self::NETHER_BRICK; + protected $id = self::NETHER_BRICK_BLOCK; public function __construct(int $meta = 0){ $this->meta = $meta; @@ -46,13 +46,11 @@ class NetherBrick extends Solid{ return 2; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_WOODEN){ - return [ - [Item::NETHER_BRICK, 0, 1], - ]; - }else{ - return []; + return parent::getDrops($item); } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/NetherBrickFence.php b/src/pocketmine/block/NetherBrickFence.php index ddcb1b21fa..974e653d9b 100644 --- a/src/pocketmine/block/NetherBrickFence.php +++ b/src/pocketmine/block/NetherBrickFence.php @@ -20,6 +20,7 @@ */ declare(strict_types=1); + namespace pocketmine\block; use pocketmine\item\Item; @@ -49,13 +50,13 @@ class NetherBrickFence extends Transparent{ return ($block instanceof NetherBrickFence) or ($block->isSolid() and !$block->isTransparent()); } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_WOODEN){ - return [ - [$this->id, $this->meta, 1], - ]; - }else{ - return []; + return parent::getDrops($item); } + + return []; } + + //TODO: fix bounding boxes } diff --git a/src/pocketmine/block/NetherReactor.php b/src/pocketmine/block/NetherReactor.php index 6ca1fb6eaf..42e824e370 100644 --- a/src/pocketmine/block/NetherReactor.php +++ b/src/pocketmine/block/NetherReactor.php @@ -50,11 +50,11 @@ class NetherReactor extends Solid{ return 3; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ - [Item::IRON_INGOT, 0, 6], - [Item::DIAMOND, 0, 3] + Item::get(Item::IRON_INGOT, 0, 6), + Item::get(Item::DIAMOND, 0, 3) ]; } diff --git a/src/pocketmine/block/NetherWartPlant.php b/src/pocketmine/block/NetherWartPlant.php index a5f0e601f5..743086f93d 100644 --- a/src/pocketmine/block/NetherWartPlant.php +++ b/src/pocketmine/block/NetherWartPlant.php @@ -33,6 +33,8 @@ use pocketmine\Player; class NetherWartPlant extends Flowable{ protected $id = Block::NETHER_WART_PLANT; + protected $itemId = Item::NETHER_WART; + public function __construct(int $meta = 0){ $this->meta = $meta; } @@ -74,7 +76,9 @@ class NetherWartPlant extends Flowable{ return false; } - public function getDrops(Item $item){ - return [[Item::NETHER_WART, 0, ($this->meta === 3 ? mt_rand(2, 4) : 1)]]; + public function getDrops(Item $item) : array{ + return [ + Item::get($this->getItemId(), 0, ($this->getDamage() === 3 ? mt_rand(2, 4) : 1)) + ]; } } \ No newline at end of file diff --git a/src/pocketmine/block/Netherrack.php b/src/pocketmine/block/Netherrack.php index 2303d77262..a8ebf6c6c1 100644 --- a/src/pocketmine/block/Netherrack.php +++ b/src/pocketmine/block/Netherrack.php @@ -46,13 +46,11 @@ class Netherrack extends Solid{ return Tool::TYPE_PICKAXE; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_WOODEN){ - return [ - [Item::NETHERRACK, 0, 1], - ]; - }else{ - return []; + return parent::getDrops($item); } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/Obsidian.php b/src/pocketmine/block/Obsidian.php index 3284b44204..7a8ff16fb2 100644 --- a/src/pocketmine/block/Obsidian.php +++ b/src/pocketmine/block/Obsidian.php @@ -43,16 +43,14 @@ class Obsidian extends Solid{ } public function getHardness() : float{ - return 35; + return 35; //50 in PC } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_DIAMOND){ - return [ - [Item::OBSIDIAN, 0, 1], - ]; - }else{ - return []; + return parent::getDrops($item); } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/Potato.php b/src/pocketmine/block/Potato.php index 99a98c12d1..341e382672 100644 --- a/src/pocketmine/block/Potato.php +++ b/src/pocketmine/block/Potato.php @@ -37,14 +37,9 @@ class Potato extends Crops{ return "Potato Block"; } - public function getDrops(Item $item){ - $drops = []; - if($this->meta >= 0x07){ - $drops[] = [Item::POTATO, 0, mt_rand(1, 4)]; - }else{ - $drops[] = [Item::POTATO, 0, 1]; - } - - return $drops; + public function getDrops(Item $item) : array{ + return [ + Item::get(Item::POTATO, 0, $this->getDamage() >= 0x07 ? mt_rand(1, 4) : 1) + ]; } } \ No newline at end of file diff --git a/src/pocketmine/block/Prismarine.php b/src/pocketmine/block/Prismarine.php index c78e2e7ebb..1443aa2441 100644 --- a/src/pocketmine/block/Prismarine.php +++ b/src/pocketmine/block/Prismarine.php @@ -55,13 +55,13 @@ class Prismarine extends Solid{ return Tool::TYPE_PICKAXE; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ - [$this->id, $this->meta & 0x03, 1], + Item::get($this->getItemId(), $this->getDamage() & 0x03, 1) ]; - }else{ - return []; } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/PumpkinStem.php b/src/pocketmine/block/PumpkinStem.php index 8735dfeb00..b2b3b799ff 100644 --- a/src/pocketmine/block/PumpkinStem.php +++ b/src/pocketmine/block/PumpkinStem.php @@ -82,9 +82,9 @@ class PumpkinStem extends Crops{ return false; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [Item::PUMPKIN_SEEDS, 0, mt_rand(0, 2)], + Item::get(Item::PUMPKIN_SEEDS, 0, mt_rand(0, 2)) ]; } } \ No newline at end of file diff --git a/src/pocketmine/block/Quartz.php b/src/pocketmine/block/Quartz.php index f98c70fb8c..4fa8115f3e 100644 --- a/src/pocketmine/block/Quartz.php +++ b/src/pocketmine/block/Quartz.php @@ -57,13 +57,13 @@ class Quartz extends Solid{ return Tool::TYPE_PICKAXE; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ - [Item::QUARTZ_BLOCK, $this->meta & 0x03, 1], + Item::get($this->getItemId(), $this->getDamage() & 0x03, 1) ]; - }else{ - return []; } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/Redstone.php b/src/pocketmine/block/Redstone.php index edc6bae76d..357eb1a6f9 100644 --- a/src/pocketmine/block/Redstone.php +++ b/src/pocketmine/block/Redstone.php @@ -46,13 +46,11 @@ class Redstone extends Solid{ return "Redstone Block"; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_WOODEN){ - return [ - [Item::REDSTONE_BLOCK, 0, 1], - ]; - }else{ - return []; + return parent::getDrops($item); } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/RedstoneOre.php b/src/pocketmine/block/RedstoneOre.php index 326418da57..dbafbf15f4 100644 --- a/src/pocketmine/block/RedstoneOre.php +++ b/src/pocketmine/block/RedstoneOre.php @@ -62,13 +62,13 @@ class RedstoneOre extends Solid{ return Tool::TYPE_PICKAXE; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_IRON){ return [ - [Item::REDSTONE_DUST, 0, mt_rand(4, 5)], + Item::get(Item::REDSTONE_DUST, 0, mt_rand(4, 5)) ]; - }else{ - return []; } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/Sandstone.php b/src/pocketmine/block/Sandstone.php index 88e5dc1e0d..a9def36c6e 100644 --- a/src/pocketmine/block/Sandstone.php +++ b/src/pocketmine/block/Sandstone.php @@ -55,14 +55,14 @@ class Sandstone extends Solid{ return Tool::TYPE_PICKAXE; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ - [Item::SANDSTONE, $this->meta & 0x03, 1], + Item::get($this->getItemId(), $this->getDamage() & 0x03, 1) ]; - }else{ - return []; } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/Sapling.php b/src/pocketmine/block/Sapling.php index 36b72bcc6b..5c6bd9d62e 100644 --- a/src/pocketmine/block/Sapling.php +++ b/src/pocketmine/block/Sapling.php @@ -107,9 +107,9 @@ class Sapling extends Flowable{ return false; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [$this->id, $this->meta & 0x07, 1], + Item::get($this->getItemId(), $this->getDamage() & 0x07, 1) ]; } diff --git a/src/pocketmine/block/SeaLantern.php b/src/pocketmine/block/SeaLantern.php index b571cb6e73..4dd87fb809 100644 --- a/src/pocketmine/block/SeaLantern.php +++ b/src/pocketmine/block/SeaLantern.php @@ -45,9 +45,9 @@ class SeaLantern extends Transparent{ return 15; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [Item::PRISMARINE_CRYSTALS, 0, 3], + Item::get(Item::PRISMARINE_CRYSTALS, 0, 3) ]; } diff --git a/src/pocketmine/block/SignPost.php b/src/pocketmine/block/SignPost.php index e6ea4579f7..13f66f6617 100644 --- a/src/pocketmine/block/SignPost.php +++ b/src/pocketmine/block/SignPost.php @@ -37,6 +37,8 @@ class SignPost extends Transparent{ protected $id = self::SIGN_POST; + protected $itemId = Item::SIGN; + public function __construct(int $meta = 0){ $this->meta = $meta; } @@ -109,12 +111,6 @@ class SignPost extends Transparent{ return false; } - public function getDrops(Item $item){ - return [ - [Item::SIGN, 0, 1], - ]; - } - public function getToolType() : int{ return Tool::TYPE_AXE; } diff --git a/src/pocketmine/block/Skull.php b/src/pocketmine/block/Skull.php index e40254c619..85bdbf1fbf 100644 --- a/src/pocketmine/block/Skull.php +++ b/src/pocketmine/block/Skull.php @@ -89,11 +89,11 @@ class Skull extends Flowable{ return false; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ $tile = $this->level->getTile($this); if($tile instanceof SkullTile){ return [ - [Item::SKULL, $tile->getType(), 1] + Item::get(Item::SKULL, $tile->getType(), 1) ]; } diff --git a/src/pocketmine/block/SnowLayer.php b/src/pocketmine/block/SnowLayer.php index b3f46f3751..06f7ea3dd5 100644 --- a/src/pocketmine/block/SnowLayer.php +++ b/src/pocketmine/block/SnowLayer.php @@ -83,10 +83,10 @@ class SnowLayer extends Flowable{ return false; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isShovel() !== false){ return [ - [Item::SNOWBALL, 0, 1], + Item::get(Item::SNOWBALL, 0, 1) //TODO: check layer count ]; } diff --git a/src/pocketmine/block/Stair.php b/src/pocketmine/block/Stair.php index 3e30107a4c..1e65c356b5 100644 --- a/src/pocketmine/block/Stair.php +++ b/src/pocketmine/block/Stair.php @@ -145,13 +145,13 @@ abstract class Stair extends Transparent{ return true; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ - [$this->getId(), 0, 1], + Item::get($this->getItemId(), 0, 1) ]; - }else{ - return []; } + + return []; } } diff --git a/src/pocketmine/block/Stone.php b/src/pocketmine/block/Stone.php index 6139a3421c..fa6edb6efc 100644 --- a/src/pocketmine/block/Stone.php +++ b/src/pocketmine/block/Stone.php @@ -62,14 +62,18 @@ class Stone extends Solid{ return $names[$this->meta & 0x07] ?? "Unknown"; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_WOODEN){ - return [ - [$this->getDamage() === 0 ? Item::COBBLESTONE : Item::STONE, $this->getDamage(), 1], - ]; - }else{ - return []; + if($this->getDamage() === self::NORMAL){ + return [ + Item::get(Item::COBBLESTONE, $this->getDamage(), 1) + ]; + } + + return parent::getDrops($item); } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/StoneBricks.php b/src/pocketmine/block/StoneBricks.php index 094b7dfd71..de33f72d8e 100644 --- a/src/pocketmine/block/StoneBricks.php +++ b/src/pocketmine/block/StoneBricks.php @@ -56,14 +56,14 @@ class StoneBricks extends Solid{ return $names[$this->meta & 0x03]; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ - [Item::STONE_BRICKS, $this->meta & 0x03, 1], + Item::get($this->getItemId(), $this->getDamage() & 0x03, 1) ]; - }else{ - return []; } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/StoneSlab.php b/src/pocketmine/block/StoneSlab.php index 80717b2c5d..3758e87c47 100644 --- a/src/pocketmine/block/StoneSlab.php +++ b/src/pocketmine/block/StoneSlab.php @@ -62,14 +62,12 @@ class StoneSlab extends WoodenSlab{ return Tool::TYPE_PICKAXE; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_WOODEN){ - return [ - [$this->id, $this->meta & 0x07, 1], - ]; - }else{ - return []; + return parent::getDrops($item); } + + return []; } public function getFuelTime() : int{ diff --git a/src/pocketmine/block/Stonecutter.php b/src/pocketmine/block/Stonecutter.php index 21c108d133..4b504ae6ec 100644 --- a/src/pocketmine/block/Stonecutter.php +++ b/src/pocketmine/block/Stonecutter.php @@ -26,7 +26,6 @@ namespace pocketmine\block; use pocketmine\item\Item; use pocketmine\item\Tool; -//TODO: check orientation class Stonecutter extends Solid{ protected $id = self::STONECUTTER; @@ -43,13 +42,11 @@ class Stonecutter extends Solid{ return Tool::TYPE_PICKAXE; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isPickaxe() >= Tool::TIER_WOODEN){ - return [ - [Item::STONECUTTER, 0, 1], - ]; - }else{ - return []; + return parent::getDrops($item); } + + return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/Sugarcane.php b/src/pocketmine/block/Sugarcane.php index 0d6ba05b89..d054291131 100644 --- a/src/pocketmine/block/Sugarcane.php +++ b/src/pocketmine/block/Sugarcane.php @@ -34,6 +34,8 @@ class Sugarcane extends Flowable{ protected $id = self::SUGARCANE_BLOCK; + protected $itemId = Item::SUGARCANE; + public function __construct(int $meta = 0){ $this->meta = $meta; } @@ -42,13 +44,6 @@ class Sugarcane extends Flowable{ return "Sugarcane"; } - - public function getDrops(Item $item){ - return [ - [Item::SUGARCANE, 0, 1], - ]; - } - public function onActivate(Item $item, Player $player = null) : bool{ if($item->getId() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal if($this->getSide(Vector3::SIDE_DOWN)->getId() !== self::SUGARCANE_BLOCK){ diff --git a/src/pocketmine/block/TallGrass.php b/src/pocketmine/block/TallGrass.php index aeac09f0d7..723f351bc2 100644 --- a/src/pocketmine/block/TallGrass.php +++ b/src/pocketmine/block/TallGrass.php @@ -73,10 +73,10 @@ class TallGrass extends Flowable{ return false; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if(mt_rand(0, 15) === 0){ return [ - [Item::WHEAT_SEEDS, 0, 1] + Item::get(Item::WHEAT_SEEDS, 0, 1) ]; } diff --git a/src/pocketmine/block/Torch.php b/src/pocketmine/block/Torch.php index 10edd3d846..52fb3aafea 100644 --- a/src/pocketmine/block/Torch.php +++ b/src/pocketmine/block/Torch.php @@ -93,9 +93,9 @@ class Torch extends Flowable{ return false; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [$this->id, 0, 1], + Item::get($this->getItemId(), 0, 1) ]; } } \ No newline at end of file diff --git a/src/pocketmine/block/Trapdoor.php b/src/pocketmine/block/Trapdoor.php index 608a886fa0..5b5f20abd8 100644 --- a/src/pocketmine/block/Trapdoor.php +++ b/src/pocketmine/block/Trapdoor.php @@ -140,9 +140,9 @@ class Trapdoor extends Transparent{ return true; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [$this->id, 0, 1], + Item::get($this->getItemId(), 0, 1) ]; } diff --git a/src/pocketmine/block/UnknownBlock.php b/src/pocketmine/block/UnknownBlock.php index 1c1f2af032..b88c379fe0 100644 --- a/src/pocketmine/block/UnknownBlock.php +++ b/src/pocketmine/block/UnknownBlock.php @@ -31,7 +31,7 @@ class UnknownBlock extends Transparent{ return 0; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/Vine.php b/src/pocketmine/block/Vine.php index 82fc25b79a..18ae763b65 100644 --- a/src/pocketmine/block/Vine.php +++ b/src/pocketmine/block/Vine.php @@ -174,14 +174,14 @@ class Vine extends Transparent{ return false; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ if($item->isShears()){ return [ - [$this->id, 0, 1], + Item::get($this->getItemId(), 0, 1) ]; - }else{ - return []; } + + return []; } public function getToolType() : int{ diff --git a/src/pocketmine/block/WaterLily.php b/src/pocketmine/block/WaterLily.php index 8d7144152d..cd47daf799 100644 --- a/src/pocketmine/block/WaterLily.php +++ b/src/pocketmine/block/WaterLily.php @@ -80,9 +80,9 @@ class WaterLily extends Flowable{ return false; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [$this->id, 0, 1] + Item::get($this->getItemId(), 0, 1) ]; } } \ No newline at end of file diff --git a/src/pocketmine/block/Wheat.php b/src/pocketmine/block/Wheat.php index 5d69a5049d..06a3a8468b 100644 --- a/src/pocketmine/block/Wheat.php +++ b/src/pocketmine/block/Wheat.php @@ -37,15 +37,16 @@ class Wheat extends Crops{ return "Wheat Block"; } - public function getDrops(Item $item){ - $drops = []; + public function getDrops(Item $item) : array{ if($this->meta >= 0x07){ - $drops[] = [Item::WHEAT, 0, 1]; - $drops[] = [Item::WHEAT_SEEDS, 0, mt_rand(0, 3)]; + return [ + Item::get(Item::WHEAT, 0, 1), + Item::get(Item::WHEAT_SEEDS, 0, mt_rand(0, 3)) + ]; }else{ - $drops[] = [Item::WHEAT_SEEDS, 0, 1]; + return [ + Item::get(Item::WHEAT_SEEDS, 0, 1) + ]; } - - return $drops; } } \ No newline at end of file diff --git a/src/pocketmine/block/Wood.php b/src/pocketmine/block/Wood.php index 7bd249a7fc..c2d6eb7f4b 100644 --- a/src/pocketmine/block/Wood.php +++ b/src/pocketmine/block/Wood.php @@ -69,9 +69,9 @@ class Wood extends Solid{ return true; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [$this->id, $this->meta & 0x03, 1], + Item::get($this->getItemId(), $this->getDamage() & 0x03, 1) ]; } diff --git a/src/pocketmine/block/WoodenDoor.php b/src/pocketmine/block/WoodenDoor.php index 70618183b8..8d946d4582 100644 --- a/src/pocketmine/block/WoodenDoor.php +++ b/src/pocketmine/block/WoodenDoor.php @@ -36,9 +36,9 @@ class WoodenDoor extends Door{ return Tool::TYPE_AXE; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [$this->getItemId(), 0, 1], + Item::get($this->getItemId(), 0, 1) ]; } } \ No newline at end of file diff --git a/src/pocketmine/block/WoodenSlab.php b/src/pocketmine/block/WoodenSlab.php index a4ade5ea75..7fe17c5361 100644 --- a/src/pocketmine/block/WoodenSlab.php +++ b/src/pocketmine/block/WoodenSlab.php @@ -129,9 +129,9 @@ class WoodenSlab extends Transparent{ return Tool::TYPE_AXE; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [$this->id, $this->meta & 0x07, 1], + Item::get($this->getItemId(), $this->getDamage() & 0x07, 1) ]; } diff --git a/src/pocketmine/block/WoodenStairs.php b/src/pocketmine/block/WoodenStairs.php index ae91ae9e5d..7fdd138efc 100644 --- a/src/pocketmine/block/WoodenStairs.php +++ b/src/pocketmine/block/WoodenStairs.php @@ -40,9 +40,9 @@ class WoodenStairs extends Stair{ return Tool::TYPE_AXE; } - public function getDrops(Item $item){ + public function getDrops(Item $item) : array{ return [ - [$this->id, 0, 1], + Item::get($this->getItemId(), 0, 1) ]; } } \ No newline at end of file diff --git a/src/pocketmine/event/block/BlockBreakEvent.php b/src/pocketmine/event/block/BlockBreakEvent.php index 6eb8e4fe89..2fcf48394c 100644 --- a/src/pocketmine/event/block/BlockBreakEvent.php +++ b/src/pocketmine/event/block/BlockBreakEvent.php @@ -39,6 +39,7 @@ class BlockBreakEvent extends BlockEvent implements Cancellable{ /** @var bool */ protected $instaBreak = false; + /** @var Item[] */ protected $blockDrops = []; public function __construct(Player $player, Block $block, Item $item, $instaBreak = false){ @@ -46,10 +47,7 @@ class BlockBreakEvent extends BlockEvent implements Cancellable{ $this->item = $item; $this->player = $player; $this->instaBreak = (bool) $instaBreak; - $drops = $player->isSurvival() ? $block->getDrops($item) : []; - foreach($drops as $i){ - $this->blockDrops[] = Item::get($i[0], $i[1], $i[2]); - } + $this->blockDrops = $player->isSurvival() ? $block->getDrops($item) : []; } public function getPlayer(){ diff --git a/src/pocketmine/level/Explosion.php b/src/pocketmine/level/Explosion.php index 742f831f29..c214ae436b 100644 --- a/src/pocketmine/level/Explosion.php +++ b/src/pocketmine/level/Explosion.php @@ -173,7 +173,7 @@ class Explosion{ $block->ignite(mt_rand(10, 30)); }elseif(mt_rand(0, 100) < $yield){ foreach($block->getDrops($air) as $drop){ - $this->level->dropItem($block->add(0.5, 0.5, 0.5), Item::get(...$drop)); + $this->level->dropItem($block->add(0.5, 0.5, 0.5), $drop); } } diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 270c221635..5eb917f3a4 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -1651,9 +1651,6 @@ class Level implements ChunkManager, Metadatable{ return false; }else{ $drops = $target->getDrops($item); //Fixes tile entities being deleted before getting drops - foreach($drops as $k => $i){ - $drops[$k] = Item::get($i[0], $i[1], $i[2]); - } } $above = $this->getBlock(new Vector3($target->x, $target->y + 1, $target->z));