pocketmine\utils\Binary::readInt PHP Méthode

readInt() public static méthode

public static readInt ( $str )
    public static function readInt($str)
    {
        if (strlen($str) != 4) {
            return 0;
        }
        if (PHP_INT_SIZE === 8) {
            return unpack("N", $str)[1] << 32 >> 32;
        } else {
            return unpack("N", $str)[1];
        }
    }

Usage Example

 /**
  * @param LevelProvider $provider
  * @param int           $x
  * @param int           $z
  * @param string        $blocks
  * @param string        $data
  * @param string        $skyLight
  * @param string        $blockLight
  * @param string        $biomeIds
  * @param int[]         $biomeColors
  * @param int[]         $heightMap
  * @param Compound[]    $entities
  * @param Compound[]    $tiles
  */
 protected function __construct($provider, $x, $z, $blocks, $data, $skyLight, $blockLight, $biomeIds = null, array $biomeColors = [], array $heightMap = [], array $entities = [], array $tiles = [])
 {
     $this->provider = $provider;
     $this->x = (int) $x;
     $this->z = (int) $z;
     $this->blocks = $blocks;
     $this->data = $data;
     $this->skyLight = $skyLight;
     $this->blockLight = $blockLight;
     if (strlen($biomeIds) === 256) {
         $this->biomeIds = $biomeIds;
     } else {
         $this->biomeIds = str_repeat("", 256);
     }
     if (count($biomeColors) === 256) {
         $this->biomeColors = $biomeColors;
     } else {
         $this->biomeColors = array_fill(0, 256, Binary::readInt("…²J"));
     }
     if (count($heightMap) === 256) {
         $this->heightMap = $heightMap;
     } else {
         $this->heightMap = array_fill(0, 256, 127);
     }
     $this->NBTtiles = $tiles;
     $this->NBTentities = $entities;
 }
All Usage Examples Of pocketmine\utils\Binary::readInt