Introduce Utils::getRandomFloat() (#6532)

Drop-in replacement for lcg_value() for PHP 8.4
This commit is contained in:
Akmal Fairuz
2024-11-26 18:33:29 +07:00
committed by GitHub
parent ae750b60d0
commit 269effcecf
12 changed files with 36 additions and 27 deletions

View File

@ -31,8 +31,8 @@ use pocketmine\event\entity\EntityTrampleFarmlandEvent;
use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing;
use pocketmine\utils\Utils;
use function intdiv;
use function lcg_value;
class Farmland extends Transparent{
public const MAX_WETNESS = 7;
@ -148,7 +148,7 @@ class Farmland extends Transparent{
}
public function onEntityLand(Entity $entity) : ?float{
if($entity instanceof Living && lcg_value() < $entity->getFallDistance() - 0.5){
if($entity instanceof Living && Utils::getRandomFloat() < $entity->getFallDistance() - 0.5){
$ev = new EntityTrampleFarmlandEvent($entity, $this);
$ev->call();
if(!$ev->isCancelled()){