mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-04 08:56:15 +00:00
Block->getBreakTime() now throws InvalidArgumentException on items with bad efficiency values
This commit is contained in:
@ -39,6 +39,7 @@ use pocketmine\metadata\MetadataValue;
|
|||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\plugin\Plugin;
|
use pocketmine\plugin\Plugin;
|
||||||
use function array_merge;
|
use function array_merge;
|
||||||
|
use function get_class;
|
||||||
use const PHP_INT_MAX;
|
use const PHP_INT_MAX;
|
||||||
|
|
||||||
class Block extends Position implements BlockIds, Metadatable{
|
class Block extends Position implements BlockIds, Metadatable{
|
||||||
@ -268,6 +269,7 @@ class Block extends Position implements BlockIds, Metadatable{
|
|||||||
* @param Item $item
|
* @param Item $item
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
|
* @throws \InvalidArgumentException if the item efficiency is not a positive number
|
||||||
*/
|
*/
|
||||||
public function getBreakTime(Item $item) : float{
|
public function getBreakTime(Item $item) : float{
|
||||||
$base = $this->getHardness();
|
$base = $this->getHardness();
|
||||||
@ -279,7 +281,7 @@ class Block extends Position implements BlockIds, Metadatable{
|
|||||||
|
|
||||||
$efficiency = $item->getMiningEfficiency($this);
|
$efficiency = $item->getMiningEfficiency($this);
|
||||||
if($efficiency <= 0){
|
if($efficiency <= 0){
|
||||||
throw new \RuntimeException("Item efficiency is invalid");
|
throw new \InvalidArgumentException(get_class($item) . " has invalid mining efficiency: expected >= 0, got $efficiency");
|
||||||
}
|
}
|
||||||
|
|
||||||
$base /= $efficiency;
|
$base /= $efficiency;
|
||||||
|
Reference in New Issue
Block a user