Made Leaves drops more generic, fix dark oak leaves not dropping apples

This commit is contained in:
Dylan K. Taylor 2017-12-13 12:57:58 +00:00
parent dc064dfa2e
commit 66562f24fb
2 changed files with 22 additions and 25 deletions

View File

@ -174,21 +174,26 @@ class Leaves extends Transparent{
}
public function getDrops(Item $item) : array{
$drops = [];
$variantMeta = $this->getVariant();
if($item->isShears()){
$drops[] = ItemFactory::get($this->getItemId(), $variantMeta, 1);
}else{
if(mt_rand(1, 20) === 1){ //Saplings
$drops[] = ItemFactory::get(Item::SAPLING, $variantMeta, 1);
}
if($variantMeta === self::OAK and mt_rand(1, 200) === 1){ //Apples
$drops[] = ItemFactory::get(Item::APPLE, 0, 1);
}
return parent::getDrops($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;
}
public function getSaplingItem() : Item{
return ItemFactory::get(Item::SAPLING, $this->getVariant());
}
public function canDropApples() : bool{
return $this->meta === self::OAK;
}
}

View File

@ -39,19 +39,11 @@ class Leaves2 extends Leaves{
return $names[$this->getVariant()] ?? "Unknown";
}
public function getDrops(Item $item) : array{
$variantMeta = $this->getVariant();
public function getSaplingItem() : Item{
return ItemFactory::get(Item::SAPLING, $this->getVariant() + 4);
}
if($item->isShears()){
return [
ItemFactory::get($this->getItemId(), $variantMeta, 1)
];
}elseif(mt_rand(1, 20) === 1){ //Saplings
return [
ItemFactory::get(Item::SAPLING, $variantMeta + 4, 1)
];
}
return [];
public function canDropApples() : bool{
return $this->meta === self::DARK_OAK;
}
}