mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-15 18:29:46 +00:00
Fixed invalid string type in writeMetadata()
This commit is contained in:
parent
c0de004472
commit
999990756c
@ -26,6 +26,11 @@ namespace pocketmine\utils;
|
|||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WARNING: This class is available on the PocketMine-MP Zephir project.
|
||||||
|
* If this class is modified, remember to modify the PHP C extension.
|
||||||
|
*/
|
||||||
class Binary{
|
class Binary{
|
||||||
const BIG_ENDIAN = 0x00;
|
const BIG_ENDIAN = 0x00;
|
||||||
const LITTLE_ENDIAN = 0x01;
|
const LITTLE_ENDIAN = 0x01;
|
||||||
@ -59,11 +64,11 @@ class Binary{
|
|||||||
* Writes a coded metadata string
|
* Writes a coded metadata string
|
||||||
* TODO: Replace and move this to entity
|
* TODO: Replace and move this to entity
|
||||||
*
|
*
|
||||||
* @param $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function writeMetadata($data){
|
public static function writeMetadata(array $data){
|
||||||
$m = "";
|
$m = "";
|
||||||
foreach($data as $bottom => $d){
|
foreach($data as $bottom => $d){
|
||||||
$m .= chr(($d[0] << 5) | ($bottom & 0b00011111));
|
$m .= chr(($d[0] << 5) | ($bottom & 0b00011111));
|
||||||
@ -81,8 +86,7 @@ class Binary{
|
|||||||
$m .= self::writeLFloat($d[1]);
|
$m .= self::writeLFloat($d[1]);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
$m .= self::writeLShort(strlen($d[1]));
|
$m .= self::writeLShort(strlen($d[1])) . $d[1];
|
||||||
$m .= $data[1];
|
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
$m .= self::writeLShort($d[1][0]);
|
$m .= self::writeLShort($d[1][0]);
|
||||||
|
@ -24,22 +24,23 @@ namespace pocketmine\utils;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Unsecure Random Number Generator, used for fast seeded values
|
* Unsecure Random Number Generator, used for fast seeded values
|
||||||
|
* WARNING: This class is available on the PocketMine-MP Zephir project.
|
||||||
|
* If this class is modified, remember to modify the PHP C extension.
|
||||||
*/
|
*/
|
||||||
class Random{
|
class Random{
|
||||||
private $z, $w;
|
private $z, $w;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int|bool $seed Integer to be used as seed. If false, generates a Random one
|
* @param int $seed Integer to be used as seed.
|
||||||
*/
|
*/
|
||||||
public function __construct($seed = false){
|
public function __construct($seed = 0){
|
||||||
$this->setSeed($seed);
|
$this->setSeed($seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int|bool $seed Integer to be used as seed. If false, generates a Random one
|
* @param int $seed Integer to be used as seed.
|
||||||
*/
|
*/
|
||||||
public function setSeed($seed = false){
|
public function setSeed($seed){
|
||||||
$seed = $seed !== false ? (int) $seed : Binary::readInt(Utils::getRandomBytes(4, false));
|
|
||||||
$this->z = $seed ^ 0xdeadbeef;
|
$this->z = $seed ^ 0xdeadbeef;
|
||||||
$this->w = $seed ^ 0xc0de1337;
|
$this->w = $seed ^ 0xc0de1337;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user