mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Cleaned up non-trivial getDrops() stuff
This commit is contained in:
parent
90eed14cd6
commit
717b36a983
@ -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);
|
||||
}
|
||||
}
|
@ -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 [];
|
||||
|
@ -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{
|
||||
|
@ -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 [];
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user