diff --git a/src/pocketmine/block/DeadBush.php b/src/pocketmine/block/DeadBush.php index d60b2945a..e5bce9315 100644 --- a/src/pocketmine/block/DeadBush.php +++ b/src/pocketmine/block/DeadBush.php @@ -56,13 +56,17 @@ class DeadBush extends Flowable{ return BlockToolType::TYPE_SHEARS; } + public function getToolHarvestLevel() : int{ + return 1; + } + public function getDrops(Item $item) : array{ - if($item->isShears()){ - return parent::getDrops($item); + if(!$this->isCompatibleWithTool($item)){ + return [ + ItemFactory::get(Item::STICK, 0, mt_rand(0, 2)) + ]; } - return [ - ItemFactory::get(Item::STICK, 0, mt_rand(0, 2)) - ]; + return parent::getDrops($item); } } \ No newline at end of file diff --git a/src/pocketmine/block/DoublePlant.php b/src/pocketmine/block/DoublePlant.php index 60835d46b..99e094b82 100644 --- a/src/pocketmine/block/DoublePlant.php +++ b/src/pocketmine/block/DoublePlant.php @@ -109,19 +109,25 @@ class DoublePlant extends Flowable{ return 0x07; } + public function getToolType() : int{ + return ($this->meta === 2 or $this->meta === 3) ? BlockToolType::TYPE_SHEARS : BlockToolType::TYPE_NONE; + } + + public function getToolHarvestLevel() : int{ + return ($this->meta === 2 or $this->meta === 3) ? 1 : 0; //only grass or fern require shears + } + public function getDrops(Item $item) : array{ if($this->meta & self::BITFLAG_TOP){ - if(!$item->isShears() and ($this->meta === 2 or $this->meta === 3)){ //grass or fern - if(mt_rand(0, 24) === 0){ - return [ - ItemFactory::get(Item::SEEDS, 0, 1) - ]; - } - - return []; + if($this->isCompatibleWithTool($item)){ + return parent::getDrops($item); } - return parent::getDrops($item); + if(mt_rand(0, 24) === 0){ + return [ + ItemFactory::get(Item::SEEDS, 0, 1) + ]; + } } return []; diff --git a/src/pocketmine/block/Leaves.php b/src/pocketmine/block/Leaves.php index 66443efd0..b06ed5b99 100644 --- a/src/pocketmine/block/Leaves.php +++ b/src/pocketmine/block/Leaves.php @@ -173,19 +173,19 @@ class Leaves extends Transparent{ } public function getDrops(Item $item) : array{ - if($item->isShears()){ - return parent::getDrops($item); + if(!$this->isCompatibleWithTool($item)){ + $drops = []; + if(mt_rand(1, 20) === 1){ //Saplings + $drops[] = $this->getSaplingItem(); + } + if($this->canDropApples() and mt_rand(1, 200) === 1){ //Apples + $drops[] = ItemFactory::get(Item::APPLE, 0, 1); + } + + return $drops; } - $drops = []; - if(mt_rand(1, 20) === 1){ //Saplings - $drops[] = $this->getSaplingItem(); - } - if($this->canDropApples() and mt_rand(1, 200) === 1){ //Apples - $drops[] = ItemFactory::get(Item::APPLE, 0, 1); - } - - return $drops; + return parent::getDrops($item); } public function getSaplingItem() : Item{ diff --git a/src/pocketmine/block/TallGrass.php b/src/pocketmine/block/TallGrass.php index b82f9d6c0..3e82a0643 100644 --- a/src/pocketmine/block/TallGrass.php +++ b/src/pocketmine/block/TallGrass.php @@ -74,15 +74,25 @@ class TallGrass extends Flowable{ return false; } + public function getToolType() : int{ + return BlockToolType::TYPE_SHEARS; + } + + public function getToolHarvestLevel() : int{ + return 1; + } + public function getDrops(Item $item) : array{ + if($this->isCompatibleWithTool($item)){ + return parent::getDrops($item); + } + if(mt_rand(0, 15) === 0){ return [ ItemFactory::get(Item::WHEAT_SEEDS, 0, 1) ]; } - //TODO: check shears - return []; } diff --git a/src/pocketmine/block/Vine.php b/src/pocketmine/block/Vine.php index f2f7cbe0e..3281206e1 100644 --- a/src/pocketmine/block/Vine.php +++ b/src/pocketmine/block/Vine.php @@ -200,7 +200,7 @@ class Vine extends Flowable{ } public function getDrops(Item $item) : array{ - if($item->isShears()){ + if($item->getBlockToolType() & BlockToolType::TYPE_SHEARS){ return $this->getDropsForCompatibleTool($item); }