mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-06 10:01:53 +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;
|
return BlockToolType::TYPE_SHEARS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item) : array{
|
public function getToolHarvestLevel() : int{
|
||||||
if($item->isShears()){
|
return 1;
|
||||||
return parent::getDrops($item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getDrops(Item $item) : array{
|
||||||
|
if(!$this->isCompatibleWithTool($item)){
|
||||||
return [
|
return [
|
||||||
ItemFactory::get(Item::STICK, 0, mt_rand(0, 2))
|
ItemFactory::get(Item::STICK, 0, mt_rand(0, 2))
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getDrops($item);
|
||||||
|
}
|
||||||
}
|
}
|
@ -109,19 +109,25 @@ class DoublePlant extends Flowable{
|
|||||||
return 0x07;
|
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{
|
public function getDrops(Item $item) : array{
|
||||||
if($this->meta & self::BITFLAG_TOP){
|
if($this->meta & self::BITFLAG_TOP){
|
||||||
if(!$item->isShears() and ($this->meta === 2 or $this->meta === 3)){ //grass or fern
|
if($this->isCompatibleWithTool($item)){
|
||||||
|
return parent::getDrops($item);
|
||||||
|
}
|
||||||
|
|
||||||
if(mt_rand(0, 24) === 0){
|
if(mt_rand(0, 24) === 0){
|
||||||
return [
|
return [
|
||||||
ItemFactory::get(Item::SEEDS, 0, 1)
|
ItemFactory::get(Item::SEEDS, 0, 1)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::getDrops($item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
|
@ -173,10 +173,7 @@ class Leaves extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item) : array{
|
public function getDrops(Item $item) : array{
|
||||||
if($item->isShears()){
|
if(!$this->isCompatibleWithTool($item)){
|
||||||
return parent::getDrops($item);
|
|
||||||
}
|
|
||||||
|
|
||||||
$drops = [];
|
$drops = [];
|
||||||
if(mt_rand(1, 20) === 1){ //Saplings
|
if(mt_rand(1, 20) === 1){ //Saplings
|
||||||
$drops[] = $this->getSaplingItem();
|
$drops[] = $this->getSaplingItem();
|
||||||
@ -188,6 +185,9 @@ class Leaves extends Transparent{
|
|||||||
return $drops;
|
return $drops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getDrops($item);
|
||||||
|
}
|
||||||
|
|
||||||
public function getSaplingItem() : Item{
|
public function getSaplingItem() : Item{
|
||||||
return ItemFactory::get(Item::SAPLING, $this->getVariant());
|
return ItemFactory::get(Item::SAPLING, $this->getVariant());
|
||||||
}
|
}
|
||||||
|
@ -74,15 +74,25 @@ class TallGrass extends Flowable{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getToolType() : int{
|
||||||
|
return BlockToolType::TYPE_SHEARS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToolHarvestLevel() : int{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item) : array{
|
public function getDrops(Item $item) : array{
|
||||||
|
if($this->isCompatibleWithTool($item)){
|
||||||
|
return parent::getDrops($item);
|
||||||
|
}
|
||||||
|
|
||||||
if(mt_rand(0, 15) === 0){
|
if(mt_rand(0, 15) === 0){
|
||||||
return [
|
return [
|
||||||
ItemFactory::get(Item::WHEAT_SEEDS, 0, 1)
|
ItemFactory::get(Item::WHEAT_SEEDS, 0, 1)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: check shears
|
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ class Vine extends Flowable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item) : array{
|
public function getDrops(Item $item) : array{
|
||||||
if($item->isShears()){
|
if($item->getBlockToolType() & BlockToolType::TYPE_SHEARS){
|
||||||
return $this->getDropsForCompatibleTool($item);
|
return $this->getDropsForCompatibleTool($item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user