mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 20:28:31 +00:00
Merge branch 'master' into tools-refactor
This commit is contained in:
commit
4452e6ac93
@ -173,21 +173,26 @@ class Leaves extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item) : array{
|
public function getDrops(Item $item) : array{
|
||||||
$drops = [];
|
|
||||||
|
|
||||||
$variantMeta = $this->getVariant();
|
|
||||||
|
|
||||||
if($item->isShears()){
|
if($item->isShears()){
|
||||||
$drops[] = ItemFactory::get($this->getItemId(), $variantMeta, 1);
|
return parent::getDrops($item);
|
||||||
}else{
|
}
|
||||||
if(mt_rand(1, 20) === 1){ //Saplings
|
|
||||||
$drops[] = ItemFactory::get(Item::SAPLING, $variantMeta, 1);
|
$drops = [];
|
||||||
}
|
if(mt_rand(1, 20) === 1){ //Saplings
|
||||||
if($variantMeta === self::OAK and mt_rand(1, 200) === 1){ //Apples
|
$drops[] = $this->getSaplingItem();
|
||||||
$drops[] = ItemFactory::get(Item::APPLE, 0, 1);
|
}
|
||||||
}
|
if($this->canDropApples() and mt_rand(1, 200) === 1){ //Apples
|
||||||
|
$drops[] = ItemFactory::get(Item::APPLE, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $drops;
|
return $drops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSaplingItem() : Item{
|
||||||
|
return ItemFactory::get(Item::SAPLING, $this->getVariant());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canDropApples() : bool{
|
||||||
|
return $this->meta === self::OAK;
|
||||||
|
}
|
||||||
}
|
}
|
@ -39,19 +39,11 @@ class Leaves2 extends Leaves{
|
|||||||
return $names[$this->getVariant()] ?? "Unknown";
|
return $names[$this->getVariant()] ?? "Unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item) : array{
|
public function getSaplingItem() : Item{
|
||||||
$variantMeta = $this->getVariant();
|
return ItemFactory::get(Item::SAPLING, $this->getVariant() + 4);
|
||||||
|
}
|
||||||
|
|
||||||
if($item->isShears()){
|
public function canDropApples() : bool{
|
||||||
return [
|
return $this->meta === self::DARK_OAK;
|
||||||
ItemFactory::get($this->getItemId(), $variantMeta, 1)
|
|
||||||
];
|
|
||||||
}elseif(mt_rand(1, 20) === 1){ //Saplings
|
|
||||||
return [
|
|
||||||
ItemFactory::get(Item::SAPLING, $variantMeta + 4, 1)
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user