BlockBreakInfo: Expose hardness multipliers as constants

This commit is contained in:
Dylan K. Taylor 2021-06-30 19:47:11 +01:00
parent 7a35fdb1bb
commit 1d8f0033af
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -27,6 +27,16 @@ use pocketmine\item\Item;
use function get_class;
class BlockBreakInfo{
/**
* If the tool is the correct type and high enough harvest level (tool tier), base break time is hardness multiplied
* by this value.
*/
public const COMPATIBLE_TOOL_MULTIPLIER = 1.5;
/**
* If the tool is an incorrect type or too low harvest level (tool tier), base break time is hardness multiplied by
* this value.
*/
public const INCOMPATIBLE_TOOL_MULTIPLIER = 5.0;
private float $hardness;
private float $blastResistance;
@ -121,9 +131,9 @@ class BlockBreakInfo{
public function getBreakTime(Item $item) : float{
$base = $this->hardness;
if($this->isToolCompatible($item)){
$base *= 1.5;
$base *= self::COMPATIBLE_TOOL_MULTIPLIER;
}else{
$base *= 5;
$base *= self::INCOMPATIBLE_TOOL_MULTIPLIER;
}
$efficiency = $item->getMiningEfficiency(($this->toolType & $item->getBlockToolType()) !== 0);