Declare tool harvest level as a property

This commit is contained in:
Dylan K. Taylor
2017-12-11 14:41:48 +00:00
parent 45983acc0d
commit dbc180315e
7 changed files with 37 additions and 9 deletions

View File

@ -195,14 +195,26 @@ class Block extends Position implements BlockIds, Metadatable{
return true;
}
/**
* @return int
*/
public function getToolType() : int{
return BlockToolType::TYPE_NONE;
}
public function getToolHarvestLevel() : int{
return 0;
}
public function canBeBrokenWith(Item $item) : bool{
if($this->getHardness() < 0){
return false;
}
$toolType = $this->getToolType();
return $toolType === BlockToolType::TYPE_NONE or ($toolType & $item->getBlockToolType()) !== 0;
//TODO: check tool harvest level (tier)
$harvestLevel = $this->getToolHarvestLevel();
return $toolType === BlockToolType::TYPE_NONE or $harvestLevel === 0 or (
($toolType & $item->getBlockToolType()) !== 0 and $item->getBlockToolHarvestLevel() >= $harvestLevel);
}
/**
@ -319,13 +331,6 @@ class Block extends Position implements BlockIds, Metadatable{
return $this->getHardness() * 5;
}
/**
* @return int
*/
public function getToolType() : int{
return BlockToolType::TYPE_NONE;
}
/**
* @return float
*/