Implemented block break XP drops

This commit is contained in:
Dylan K. Taylor
2018-04-15 19:03:18 +01:00
parent 1e2122d854
commit 532269a484
9 changed files with 84 additions and 3 deletions

View File

@ -471,6 +471,30 @@ class Block extends Position implements BlockIds, Metadatable{
];
}
/**
* Returns how much XP will be dropped by breaking this block with the given item.
*
* @param Item $item
*
* @return int
*/
public function getXpDropForTool(Item $item) : int{
if($item->hasEnchantment(Enchantment::SILK_TOUCH) or !$this->isCompatibleWithTool($item)){
return 0;
}
return $this->getXpDropAmount();
}
/**
* Returns how much XP this block will drop when broken with an appropriate tool.
*
* @return int
*/
protected function getXpDropAmount() : int{
return 0;
}
/**
* Returns whether Silk Touch enchanted tools will cause this block to drop as itself. Since most blocks drop
* themselves anyway, this is implicitly true.