mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-09 11:31:49 +00:00
ItemFrame: added missing bounds check for setItemDropChance()
This commit is contained in:
parent
6d584cf008
commit
879476d8e0
@ -31,6 +31,8 @@ use pocketmine\math\Facing;
|
|||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\player\Player;
|
use pocketmine\player\Player;
|
||||||
use pocketmine\world\BlockTransaction;
|
use pocketmine\world\BlockTransaction;
|
||||||
|
use function is_infinite;
|
||||||
|
use function is_nan;
|
||||||
use function lcg_value;
|
use function lcg_value;
|
||||||
|
|
||||||
class ItemFrame extends Flowable{
|
class ItemFrame extends Flowable{
|
||||||
@ -111,6 +113,9 @@ class ItemFrame extends Flowable{
|
|||||||
|
|
||||||
/** @return $this */
|
/** @return $this */
|
||||||
public function setItemDropChance(float $itemDropChance) : self{
|
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;
|
$this->itemDropChance = $itemDropChance;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user