ItemFrame: added missing bounds check for setItemDropChance()

This commit is contained in:
Dylan K. Taylor 2022-03-09 22:20:04 +00:00
parent 6d584cf008
commit 879476d8e0
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -31,6 +31,8 @@ use pocketmine\math\Facing;
use pocketmine\math\Vector3;
use pocketmine\player\Player;
use pocketmine\world\BlockTransaction;
use function is_infinite;
use function is_nan;
use function lcg_value;
class ItemFrame extends Flowable{
@ -111,6 +113,9 @@ class ItemFrame extends Flowable{
/** @return $this */
public function setItemDropChance(float $itemDropChance) : self{
if($itemDropChance < 0.0 || $itemDropChance > 1.0 || is_nan($itemDropChance) || is_infinite($itemDropChance)){
throw new \InvalidArgumentException("Drop chance must be in range 0-1");
}
$this->itemDropChance = $itemDropChance;
return $this;
}