diff --git a/src/pocketmine/block/Anvil.php b/src/pocketmine/block/Anvil.php index 1b84dd6c7..6be3fd084 100644 --- a/src/pocketmine/block/Anvil.php +++ b/src/pocketmine/block/Anvil.php @@ -110,13 +110,9 @@ class Anvil extends Fallable{ return $this->getLevel()->setBlock($blockReplace, $this, true, true); } - public function getDrops(Item $item) : array{ - if($this->isCompatibleWithTool($item)){ - return [ - ItemFactory::get($this->getItemId(), $this->getDamage() & 0x0c, 1) - ]; - } - - return []; + public function getDropsForCompatibleTool(Item $item) : array{ + return [ + ItemFactory::get($this->getItemId(), $this->getDamage() & 0x0c, 1) + ]; } } \ No newline at end of file diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index 54cd30511..9f72ad9fb 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -434,14 +434,25 @@ class Block extends Position implements BlockIds, Metadatable{ */ public function getDrops(Item $item) : array{ if($this->isCompatibleWithTool($item)){ - return [ - ItemFactory::get($this->getItemId(), $this->getVariant(), 1) - ]; + return $this->getDropsForCompatibleTool($item); } return []; } + /** + * Returns an array of Items to be dropped when the block is broken using the correct tool type. + * + * @param Item $item + * + * @return Item[] + */ + public function getDropsForCompatibleTool(Item $item) : array{ + return [ + ItemFactory::get($this->getItemId(), $this->getVariant(), 1) + ]; + } + /** * Returns the item that players will equip when middle-clicking on this block. * @return Item diff --git a/src/pocketmine/block/CoalOre.php b/src/pocketmine/block/CoalOre.php index 902ab6c0d..e8b1d25a0 100644 --- a/src/pocketmine/block/CoalOre.php +++ b/src/pocketmine/block/CoalOre.php @@ -51,14 +51,10 @@ class CoalOre extends Solid{ return "Coal Ore"; } - public function getDrops(Item $item) : array{ - if($this->isCompatibleWithTool($item)){ - return [ - ItemFactory::get(Item::COAL, 0, 1) - ]; - } - - return []; + public function getDropsForCompatibleTool(Item $item) : array{ + return [ + ItemFactory::get(Item::COAL, 0, 1) + ]; } } \ No newline at end of file diff --git a/src/pocketmine/block/DiamondOre.php b/src/pocketmine/block/DiamondOre.php index 730d5810a..0c0beb6a5 100644 --- a/src/pocketmine/block/DiamondOre.php +++ b/src/pocketmine/block/DiamondOre.php @@ -51,13 +51,9 @@ class DiamondOre extends Solid{ return TieredTool::TIER_IRON; } - public function getDrops(Item $item) : array{ - if($this->isCompatibleWithTool($item)){ - return [ - ItemFactory::get(Item::DIAMOND, 0, 1) - ]; - } - - return []; + public function getDropsForCompatibleTool(Item $item) : array{ + return [ + ItemFactory::get(Item::DIAMOND, 0, 1) + ]; } } \ No newline at end of file diff --git a/src/pocketmine/block/EmeraldOre.php b/src/pocketmine/block/EmeraldOre.php index 36c102942..bd6cffb27 100644 --- a/src/pocketmine/block/EmeraldOre.php +++ b/src/pocketmine/block/EmeraldOre.php @@ -51,13 +51,9 @@ class EmeraldOre extends Solid{ return 3; } - public function getDrops(Item $item) : array{ - if($this->isCompatibleWithTool($item)){ - return [ + public function getDropsForCompatibleTool(Item $item) : array{ + return [ ItemFactory::get(Item::EMERALD, 0, 1) - ]; - } - - return []; + ]; } } \ No newline at end of file diff --git a/src/pocketmine/block/EnderChest.php b/src/pocketmine/block/EnderChest.php index a56e1fa14..7a206695a 100644 --- a/src/pocketmine/block/EnderChest.php +++ b/src/pocketmine/block/EnderChest.php @@ -101,14 +101,10 @@ class EnderChest extends Chest{ return true; } - public function getDrops(Item $item) : array{ - if($this->isCompatibleWithTool($item)){ - return [ - ItemFactory::get(Item::OBSIDIAN, 0, 8) - ]; - } - - return []; + public function getDropsForCompatibleTool(Item $item) : array{ + return [ + ItemFactory::get(Item::OBSIDIAN, 0, 8) + ]; } public function getFuelTime() : int{ diff --git a/src/pocketmine/block/LapisOre.php b/src/pocketmine/block/LapisOre.php index 9baf17706..91d3cd69a 100644 --- a/src/pocketmine/block/LapisOre.php +++ b/src/pocketmine/block/LapisOre.php @@ -51,14 +51,10 @@ class LapisOre extends Solid{ return "Lapis Lazuli Ore"; } - public function getDrops(Item $item) : array{ - if($this->isCompatibleWithTool($item)){ - return [ - ItemFactory::get(Item::DYE, 4, mt_rand(4, 8)) - ]; - } - - return []; + public function getDropsForCompatibleTool(Item $item) : array{ + return [ + ItemFactory::get(Item::DYE, 4, mt_rand(4, 8)) + ]; } } \ No newline at end of file diff --git a/src/pocketmine/block/NetherQuartzOre.php b/src/pocketmine/block/NetherQuartzOre.php index b9033f661..ec712d1df 100644 --- a/src/pocketmine/block/NetherQuartzOre.php +++ b/src/pocketmine/block/NetherQuartzOre.php @@ -51,14 +51,10 @@ class NetherQuartzOre extends Solid{ return TieredTool::TIER_WOODEN; } - public function getDrops(Item $item) : array{ - if($this->isCompatibleWithTool($item)){ - return [ - ItemFactory::get(Item::QUARTZ, 0, 1) - ]; - } - - return []; + public function getDropsForCompatibleTool(Item $item) : array{ + return [ + ItemFactory::get(Item::QUARTZ, 0, 1) + ]; } } \ No newline at end of file diff --git a/src/pocketmine/block/NetherReactor.php b/src/pocketmine/block/NetherReactor.php index 3bd16fb57..faf9b99a4 100644 --- a/src/pocketmine/block/NetherReactor.php +++ b/src/pocketmine/block/NetherReactor.php @@ -55,15 +55,11 @@ class NetherReactor extends Solid{ return 3; } - public function getDrops(Item $item) : array{ - if($this->isCompatibleWithTool($item)){ - return [ - ItemFactory::get(Item::IRON_INGOT, 0, 6), - ItemFactory::get(Item::DIAMOND, 0, 3) - ]; - } - - return []; + public function getDropsForCompatibleTool(Item $item) : array{ + return [ + ItemFactory::get(Item::IRON_INGOT, 0, 6), + ItemFactory::get(Item::DIAMOND, 0, 3) + ]; } } \ No newline at end of file diff --git a/src/pocketmine/block/RedstoneOre.php b/src/pocketmine/block/RedstoneOre.php index 864f95ec9..3a6a3f64c 100644 --- a/src/pocketmine/block/RedstoneOre.php +++ b/src/pocketmine/block/RedstoneOre.php @@ -68,13 +68,9 @@ class RedstoneOre extends Solid{ return TieredTool::TIER_IRON; } - public function getDrops(Item $item) : array{ - if($this->isCompatibleWithTool($item)){ - return [ - ItemFactory::get(Item::REDSTONE_DUST, 0, mt_rand(4, 5)) - ]; - } - - return []; + public function getDropsForCompatibleTool(Item $item) : array{ + return [ + ItemFactory::get(Item::REDSTONE_DUST, 0, mt_rand(4, 5)) + ]; } } \ No newline at end of file diff --git a/src/pocketmine/block/Stone.php b/src/pocketmine/block/Stone.php index a495798f9..ddbfdcc51 100644 --- a/src/pocketmine/block/Stone.php +++ b/src/pocketmine/block/Stone.php @@ -67,18 +67,14 @@ class Stone extends Solid{ return $names[$this->getVariant()] ?? "Unknown"; } - public function getDrops(Item $item) : array{ - if($this->isCompatibleWithTool($item)){ - if($this->getDamage() === self::NORMAL){ - return [ - ItemFactory::get(Item::COBBLESTONE, $this->getDamage(), 1) - ]; - } - - return parent::getDrops($item); + public function getDropsForCompatibleTool(Item $item) : array{ + if($this->getDamage() === self::NORMAL){ + return [ + ItemFactory::get(Item::COBBLESTONE, $this->getDamage(), 1) + ]; } - return []; + return parent::getDropsForCompatibleTool($item); } } \ No newline at end of file