Added Block->getDropsForCompatibleTool(), removed lots of boilerplate code from subclasses

The function name is a little long-winded, but that can always be refactored later if needed. This provides a way for blocks requiring specific tools to override drops with non-standard stuff without needing to worry about what tool type was used.

It's also possible that passing the Item used here is actually entirely redundant, but again that can be fixed later.
This commit is contained in:
Dylan K. Taylor
2017-12-12 20:02:50 +00:00
parent da3640357c
commit b9b50dd5dc
11 changed files with 56 additions and 85 deletions

View File

@ -51,14 +51,10 @@ class LapisOre extends Solid{
return "Lapis Lazuli Ore";
}
public function getDrops(Item $item) : array{
if($this->isCompatibleWithTool($item)){
return [
ItemFactory::get(Item::DYE, 4, mt_rand(4, 8))
];
}
return [];
public function getDropsForCompatibleTool(Item $item) : array{
return [
ItemFactory::get(Item::DYE, 4, mt_rand(4, 8))
];
}
}