mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 08:39:53 +00:00
Random generator with signed int/float methods
This commit is contained in:
parent
3cbcb4871a
commit
26772082da
@ -47,10 +47,18 @@ class Random{
|
||||
return Utils::readInt($this->nextBytes(4)) & 0x7FFFFFFF;
|
||||
}
|
||||
|
||||
public function nextSignedInt(){
|
||||
return Utils::readInt($this->nextBytes(4));
|
||||
}
|
||||
|
||||
public function nextFloat(){
|
||||
return $this->nextInt() / 0x7FFFFFFF;
|
||||
}
|
||||
|
||||
public function nextSignedFloat(){
|
||||
return $this->nextSignedInt() / 0x7FFFFFFF;
|
||||
}
|
||||
|
||||
public function nextBytes($byteCount){
|
||||
$bytes = "";
|
||||
for($i = 0; $i < $byteCount; ++$i){
|
||||
|
Loading…
x
Reference in New Issue
Block a user