mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-13 15:05:33 +00:00
Block: added getDropsForIncompatibleTool()
This commit is contained in:
parent
e4ed7bc4ea
commit
7dcc4891ca
@ -369,6 +369,15 @@ class Block{
|
|||||||
return [$this->asItem()];
|
return [$this->asItem()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the items dropped by this block when broken with an incorrect tool type (or tool with a too-low tier).
|
||||||
|
*
|
||||||
|
* @return Item[]
|
||||||
|
*/
|
||||||
|
public function getDropsForIncompatibleTool(Item $item) : array{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of Items to be dropped when the block is broken using a compatible Silk Touch-enchanted tool.
|
* Returns an array of Items to be dropped when the block is broken using a compatible Silk Touch-enchanted tool.
|
||||||
*
|
*
|
||||||
|
@ -47,14 +47,10 @@ class DeadBush extends Flowable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item) : array{
|
public function getDropsForIncompatibleTool(Item $item) : array{
|
||||||
if(!$this->breakInfo->isToolCompatible($item)){
|
return [
|
||||||
return [
|
VanillaItems::STICK()->setCount(mt_rand(0, 2))
|
||||||
VanillaItems::STICK()->setCount(mt_rand(0, 2))
|
];
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::getDrops($item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isAffectedBySilkTouch() : bool{
|
public function isAffectedBySilkTouch() : bool{
|
||||||
|
@ -33,12 +33,10 @@ class DoubleTallGrass extends DoublePlant{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item) : array{
|
public function getDropsForIncompatibleTool(Item $item) : array{
|
||||||
if($this->top and !$this->breakInfo->isToolCompatible($item) and mt_rand(0, 7) === 0){
|
if($this->top and mt_rand(0, 7) === 0){
|
||||||
return [
|
return [VanillaItems::WHEAT_SEEDS()];
|
||||||
VanillaItems::WHEAT_SEEDS()
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
return parent::getDrops($item);
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,11 +52,7 @@ class TallGrass extends Flowable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item) : array{
|
public function getDropsForIncompatibleTool(Item $item) : array{
|
||||||
if($this->breakInfo->isToolCompatible($item)){
|
|
||||||
return parent::getDrops($item);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(mt_rand(0, 15) === 0){
|
if(mt_rand(0, 15) === 0){
|
||||||
return [
|
return [
|
||||||
VanillaItems::WHEAT_SEEDS()
|
VanillaItems::WHEAT_SEEDS()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user