当前位置: 首页>>代码示例>>PHP>>正文


PHP Binary::readInt方法代码示例

本文整理汇总了PHP中pocketmine\utils\Binary::readInt方法的典型用法代码示例。如果您正苦于以下问题:PHP Binary::readInt方法的具体用法?PHP Binary::readInt怎么用?PHP Binary::readInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\utils\Binary的用法示例。


在下文中一共展示了Binary::readInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * @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;
 }
开发者ID:hlogeon,项目名称:PocketMineJs-MP,代码行数:41,代码来源:BaseFullChunk.php

示例2: generateChunk

 public function generateChunk($x, $z)
 {
     $nbt = new Compound("Level", []);
     $nbt->xPos = new Int("xPos", $this->getX() * 32 + $x);
     $nbt->zPos = new Int("zPos", $this->getZ() * 32 + $z);
     $nbt->LastUpdate = new Long("LastUpdate", 0);
     $nbt->LightPopulated = new Byte("LightPopulated", 0);
     $nbt->TerrainPopulated = new Byte("TerrainPopulated", 0);
     $nbt->V = new Byte("V", self::VERSION);
     $nbt->InhabitedTime = new Long("InhabitedTime", 0);
     $biomes = str_repeat(Binary::writeByte(-1), 256);
     $nbt->Biomes = new ByteArray("Biomes", $biomes);
     $nbt->BiomeColors = new IntArray("BiomeColors", array_fill(0, 156, Binary::readInt("…²J")));
     $nbt->HeightMap = new IntArray("HeightMap", array_fill(0, 256, 127));
     $nbt->Sections = new Enum("Sections", []);
     $nbt->Sections->setTagType(NBT::TAG_Compound);
     $nbt->Entities = new Enum("Entities", []);
     $nbt->Entities->setTagType(NBT::TAG_Compound);
     $nbt->TileEntities = new Enum("TileEntities", []);
     $nbt->TileEntities->setTagType(NBT::TAG_Compound);
     $nbt->TileTicks = new Enum("TileTicks", []);
     $nbt->TileTicks->setTagType(NBT::TAG_Compound);
     $writer = new NBT(NBT::BIG_ENDIAN);
     $nbt->setName("Level");
     $writer->setData(new Compound("", ["Level" => $nbt]));
     $chunkData = $writer->writeCompressed(ZLIB_ENCODING_DEFLATE, RegionLoader::$COMPRESSION_LEVEL);
     $this->saveChunk($x, $z, $chunkData);
 }
开发者ID:TylerGames,项目名称:PocketMine-MP,代码行数:28,代码来源:RegionLoader.php

示例3: __construct

 /**
  * @param LevelProvider  $provider
  * @param int            $x
  * @param int            $z
  * @param ChunkSection[] $sections
  * @param string         $biomeIds
  * @param int[]          $biomeColors
  * @param int[]          $heightMap
  * @param Compound[]     $entities
  * @param Compound[]     $tiles
  *
  * @throws ChunkException
  */
 protected function __construct($provider, $x, $z, array $sections, $biomeIds = null, array $biomeColors = [], array $heightMap = [], array $entities = [], array $tiles = [])
 {
     $this->provider = $provider;
     $this->x = (int) $x;
     $this->z = (int) $z;
     foreach ($sections as $Y => $section) {
         if ($section instanceof ChunkSection) {
             $this->sections[$Y] = $section;
         } else {
             throw new ChunkException("Received invalid ChunkSection instance");
         }
         if ($Y >= self::SECTION_COUNT) {
             throw new ChunkException("Invalid amount of chunks");
         }
     }
     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;
 }
开发者ID:TylerGames,项目名称:PocketMine-MP,代码行数:46,代码来源:BaseChunk.php

示例4: handle

 public function handle($address, $port, $packet)
 {
     $offset = 2;
     $packetType = ord($packet[$offset++]);
     $sessionID = Binary::readInt(substr($packet, $offset, 4));
     $offset += 4;
     $payload = substr($packet, $offset);
     switch ($packetType) {
         case self::HANDSHAKE:
             //Handshake
             $reply = chr(self::HANDSHAKE);
             $reply .= Binary::writeInt($sessionID);
             $reply .= self::getTokenString($this->token, $address) . "";
             $this->server->getNetwork()->sendPacket($address, $port, $reply);
             break;
         case self::STATISTICS:
             //Stat
             $token = Binary::readInt(substr($payload, 0, 4));
             if ($token !== self::getTokenString($this->token, $address) and $token !== self::getTokenString($this->lastToken, $address)) {
                 break;
             }
             $reply = chr(self::STATISTICS);
             $reply .= Binary::writeInt($sessionID);
             if ($this->timeout < microtime(true)) {
                 $this->regenerateInfo();
             }
             if (strlen($payload) === 8) {
                 $reply .= $this->longData;
             } else {
                 $reply .= $this->shortData;
             }
             $this->server->getNetwork()->sendPacket($address, $port, $reply);
             break;
     }
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:35,代码来源:QueryHandler.php

示例5: __construct

 public function __construct($level, Compound $nbt)
 {
     $this->nbt = $nbt;
     if (!isset($this->nbt->Entities) or !$this->nbt->Entities instanceof Enum) {
         $this->nbt->Entities = new Enum("Entities", []);
         $this->nbt->Entities->setTagType(NBT::TAG_Compound);
     }
     if (!isset($this->nbt->TileEntities) or !$this->nbt->TileEntities instanceof Enum) {
         $this->nbt->TileEntities = new Enum("TileEntities", []);
         $this->nbt->TileEntities->setTagType(NBT::TAG_Compound);
     }
     if (!isset($this->nbt->TileTicks) or !$this->nbt->TileTicks instanceof Enum) {
         $this->nbt->TileTicks = new Enum("TileTicks", []);
         $this->nbt->TileTicks->setTagType(NBT::TAG_Compound);
     }
     if (!isset($this->nbt->Sections) or !$this->nbt->Sections instanceof Enum) {
         $this->nbt->Sections = new Enum("Sections", []);
         $this->nbt->Sections->setTagType(NBT::TAG_Compound);
     }
     if (!isset($this->nbt->Biomes) or !$this->nbt->Biomes instanceof ByteArray) {
         $this->nbt->Biomes = new ByteArray("Biomes", \str_repeat("", 256));
     }
     if (!isset($this->nbt->BiomeColors) or !$this->nbt->BiomeColors instanceof IntArray) {
         $this->nbt->BiomeColors = new IntArray("BiomeColors", array_fill(0, 256, Binary::readInt("…²J")));
     }
     if (!isset($this->nbt->HeightMap) or !$this->nbt->HeightMap instanceof IntArray) {
         $this->nbt->HeightMap = new IntArray("HeightMap", \array_fill(0, 256, 127));
     }
     $sections = [];
     foreach ($this->nbt->Sections as $section) {
         if ($section instanceof Compound) {
             $y = (int) $section["Y"];
             if ($y < 8) {
                 $sections[$y] = new ChunkSection($section);
             }
         }
     }
     for ($y = 0; $y < 8; ++$y) {
         if (!isset($sections[$y])) {
             $sections[$y] = new EmptyChunkSection($y);
         }
     }
     parent::__construct($level, (int) $this->nbt["xPos"], (int) $this->nbt["zPos"], $sections, $this->nbt->Biomes->getValue(), $this->nbt->BiomeColors->getValue(), $this->nbt->HeightMap->getValue(), $this->nbt->Entities->getValue(), $this->nbt->TileEntities->getValue());
     unset($this->nbt->Sections);
 }
开发者ID:Cybertechpp,项目名称:Steadfast2,代码行数:45,代码来源:Chunk.php

示例6: __construct

 public function __construct($level, Compound $nbt)
 {
     $this->nbt = $nbt;
     if (isset($this->nbt->Entities) and $this->nbt->Entities instanceof Enum) {
         $this->nbt->Entities->setTagType(NBT::TAG_Compound);
     } else {
         $this->nbt->Entities = new Enum("Entities", []);
         $this->nbt->Entities->setTagType(NBT::TAG_Compound);
     }
     if (isset($this->nbt->TileEntities) and $this->nbt->TileEntities instanceof Enum) {
         $this->nbt->TileEntities->setTagType(NBT::TAG_Compound);
     } else {
         $this->nbt->TileEntities = new Enum("TileEntities", []);
         $this->nbt->TileEntities->setTagType(NBT::TAG_Compound);
     }
     if (isset($this->nbt->TileTicks) and $this->nbt->TileTicks instanceof Enum) {
         $this->nbt->TileTicks->setTagType(NBT::TAG_Compound);
     } else {
         $this->nbt->TileTicks = new Enum("TileTicks", []);
         $this->nbt->TileTicks->setTagType(NBT::TAG_Compound);
     }
     if (!isset($this->nbt->Biomes) or !$this->nbt->Biomes instanceof ByteArray) {
         $this->nbt->Biomes = new ByteArray("Biomes", str_repeat("", 256));
     }
     if (!isset($this->nbt->BiomeColors) or !$this->nbt->BiomeColors instanceof IntArray) {
         $this->nbt->BiomeColors = new IntArray("BiomeColors", array_fill(0, 256, Binary::readInt("…²J")));
     }
     if (!isset($this->nbt->HeightMap) or !$this->nbt->HeightMap instanceof IntArray) {
         $this->nbt->HeightMap = new IntArray("HeightMap", array_fill(0, 256, 127));
     }
     if (!isset($this->nbt->Blocks)) {
         $this->nbt->Blocks = new ByteArray("Blocks", str_repeat("", 32768));
     }
     if (!isset($this->nbt->Data)) {
         $this->nbt->Data = new ByteArray("Data", $half = str_repeat("", 16384));
         $this->nbt->SkyLight = new ByteArray("SkyLight", $half);
         $this->nbt->BlockLight = new ByteArray("BlockLight", $half);
     }
     parent::__construct($level, $this->nbt["xPos"], $this->nbt["zPos"], $this->nbt->Blocks->getValue(), $this->nbt->Data->getValue(), $this->nbt->SkyLight->getValue(), $this->nbt->BlockLight->getValue(), $this->nbt->Biomes->getValue(), $this->nbt->BiomeColors->getValue(), $this->nbt->HeightMap->getValue(), $this->nbt->Entities->getValue(), $this->nbt->TileEntities->getValue());
     unset($this->nbt->Blocks);
     unset($this->nbt->Data);
     unset($this->nbt->SkyLight);
     unset($this->nbt->BlockLight);
 }
开发者ID:hlogeon,项目名称:PocketMineJs-MP,代码行数:44,代码来源:Chunk.php

示例7: generateLevel

 /**
  * Generates a new level if it does not exists
  *
  * @param string $name
  * @param int    $seed
  * @param string $generator Class name that extends pocketmine\level\generator\Generator
  * @param array  $options
  *
  * @return bool
  */
 public function generateLevel($name, $seed = null, $generator = null, $options = [])
 {
     if (trim($name) === "" or $this->isLevelGenerated($name)) {
         return false;
     }
     $seed = $seed === null ? Binary::readInt(@Utils::getRandomBytes(4, false)) : (int) $seed;
     if ($generator !== null and class_exists($generator) and is_subclass_of($generator, Generator::class)) {
         $generator = new $generator($options);
     } else {
         $options["preset"] = $this->getConfigString("generator-settings", "");
         $generator = Generator::getGenerator($this->getLevelType());
     }
     if (($provider = LevelProviderManager::getProviderByName($providerName = $this->getProperty("level-settings.default-format", "mcregion"))) === null) {
         $provider = LevelProviderManager::getProviderByName($providerName = "mcregion");
     }
     try {
         $path = $this->getDataPath() . "worlds/" . $name . "/";
         /** @var \pocketmine\level\format\LevelProvider $provider */
         $provider::generate($path, $name, $seed, $generator, $options);
         $level = new Level($this, $name, $path, $provider);
         $this->levels[$level->getId()] = $level;
         $level->initLevel();
     } catch (\Exception $e) {
         $this->logger->error("Could not generate level \"" . $name . "\": " . $e->getMessage());
         if ($this->logger instanceof MainLogger) {
             $this->logger->logException($e);
         }
         return false;
     }
     $this->getPluginManager()->callEvent(new LevelInitEvent($level));
     $this->getPluginManager()->callEvent(new LevelLoadEvent($level));
     $this->getLogger()->notice("Spawn terrain for level \"{$name}\" is being generated in the background");
     $radiusSquared = ($this->getViewDistance() + 1) / M_PI;
     $radius = ceil(sqrt($radiusSquared));
     $centerX = $level->getSpawnLocation()->getX() >> 4;
     $centerZ = $level->getSpawnLocation()->getZ() >> 4;
     $order = [];
     for ($X = -$radius; $X <= $radius; ++$X) {
         for ($Z = -$radius; $Z <= $radius; ++$Z) {
             $distance = $X ** 2 + $Z ** 2;
             if ($distance > $radiusSquared) {
                 continue;
             }
             $chunkX = $X + $centerX;
             $chunkZ = $Z + $centerZ;
             $index = Level::chunkHash($chunkX, $chunkZ);
             $order[$index] = $distance;
         }
     }
     asort($order);
     $chunkX = $chunkZ = null;
     foreach ($order as $index => $distance) {
         Level::getXZ($index, $chunkX, $chunkZ);
         $level->generateChunk($chunkX, $chunkZ);
     }
     return true;
 }
开发者ID:hlogeon,项目名称:PocketMineJs-MP,代码行数:67,代码来源:Server.php

示例8: readInt

 public function readInt($signed = true)
 {
     $int = Binary::readInt($this->read(4));
     if (!$signed and $int < 0) {
         $int += 0x100000000;
     }
     return $int;
 }
开发者ID:barnseyminesuk,项目名称:Small-ZC-Plugins,代码行数:8,代码来源:StringReader.php

示例9: getInt

 public function getInt()
 {
     return $this->endianness === self::BIG_ENDIAN ? Binary::readInt($this->get(4)) : Binary::readLInt($this->get(4));
 }
开发者ID:ianju,项目名称:PocketMine-MP,代码行数:4,代码来源:NBT.php

示例10: loadChunk

 public function loadChunk($X, $Z)
 {
     if ($this->isChunkLoaded($X, $Z)) {
         return true;
     }
     $index = self::getIndex($X, $Z);
     $path = $this->getChunkPath($X, $Z);
     if (!file_exists($path)) {
         if ($this->generateChunk($X, $Z) === false) {
             return false;
         }
         if ($this->isGenerating === 0) {
             $this->populateChunk($X, $Z);
         }
         return true;
     }
     $chunk = file_get_contents($path);
     if ($chunk === false) {
         return false;
     }
     $chunk = zlib_decode($chunk);
     $offset = 0;
     $this->chunkInfo[$index] = [0 => ord($chunk[0]), 1 => Binary::readInt(substr($chunk, 1, 4))];
     $offset += 5;
     $len = Binary::readInt(substr($chunk, $offset, 4));
     $offset += 4;
     $nbt = new NBT(NBT::BIG_ENDIAN);
     $nbt->read(substr($chunk, $offset, $len));
     $this->chunkInfo[$index][2] = $nbt->getData();
     $offset += $len;
     $this->chunks[$index] = [];
     $this->chunkChange[$index] = [-1 => false];
     $this->chunkInfo[$index][3] = substr($chunk, $offset, 256);
     //Biome data
     $offset += 256;
     for ($Y = 0; $Y < 8; ++$Y) {
         if (($this->chunkInfo[$index][0] & 1 << $Y) !== 0) {
             // 4096 + 2048 + 2048, Block Data, Meta, Light
             if (strlen($this->chunks[$index][$Y] = substr($chunk, $offset, 8192)) < 8192) {
                 MainLogger::getLogger()->notice("Empty corrupt chunk detected [{$X},{$Z},:{$Y}], recovering contents");
                 $this->fillMiniChunk($X, $Z, $Y);
             }
             $offset += 8192;
         } else {
             $this->chunks[$index][$Y] = false;
         }
     }
     if ($this->isGenerating === 0 and !$this->isPopulated($X, $Z)) {
         $this->populateChunk($X, $Z);
     }
     return true;
 }
开发者ID:rryy,项目名称:PocketMine-MP,代码行数:52,代码来源:LevelFormat.php

示例11: generateLevel

 /**
  * Generates a new level if it does not exists
  *
  * @param string $name
  * @param int    $seed
  * @param string $generator Class name that extends pocketmine\level\generator\Noise
  * @param array  $options
  *
  * @return bool
  */
 public function generateLevel($name, $seed = null, $generator = null, $options = [])
 {
     if (trim($name) === "" or $this->isLevelGenerated($name)) {
         return false;
     }
     $seed = $seed === null ? Binary::readInt(@Utils::getRandomBytes(4, false)) : (int) $seed;
     if (!isset($options["preset"])) {
         $options["preset"] = $this->getConfigString("generator-settings", "");
     }
     if (!($generator !== null and class_exists($generator, true) and is_subclass_of($generator, Generator::class))) {
         $generator = Generator::getGenerator($this->getLevelType());
     }
     if (($provider = LevelProviderManager::getProviderByName($providerName = $this->getProperty("level-settings.default-format", "mcregion"))) === null) {
         $provider = LevelProviderManager::getProviderByName($providerName = "mcregion");
     }
     try {
         $path = $this->getDataPath() . "worlds/" . $name . "/";
         /** @var \pocketmine\level\format\LevelProvider $provider */
         $provider::generate($path, $name, $seed, $generator, $options);
         $level = new Level($this, $name, $path, $provider);
         $this->levels[$level->getId()] = $level;
         $level->initLevel();
         $level->setTickRate($this->baseTickRate);
     } catch (\Exception $e) {
         $this->logger->error($this->getLanguage()->translateString("pocketmine.level.generateError", [$name, $e->getMessage()]));
         if ($this->logger instanceof MainLogger) {
             $this->logger->logException($e);
         }
         return false;
     }
     $this->getPluginManager()->callEvent(new LevelInitEvent($level));
     $this->getPluginManager()->callEvent(new LevelLoadEvent($level));
     $this->getLogger()->notice($this->getLanguage()->translateString("pocketmine.level.backgroundGeneration", [$name]));
     $centerX = $level->getSpawnLocation()->getX() >> 4;
     $centerZ = $level->getSpawnLocation()->getZ() >> 4;
     $order = [];
     for ($X = -3; $X <= 3; ++$X) {
         for ($Z = -3; $Z <= 3; ++$Z) {
             $distance = $X ** 2 + $Z ** 2;
             $chunkX = $X + $centerX;
             $chunkZ = $Z + $centerZ;
             $index = Level::chunkHash($chunkX, $chunkZ);
             $order[$index] = $distance;
         }
     }
     asort($order);
     foreach ($order as $index => $distance) {
         Level::getXZ($index, $chunkX, $chunkZ);
         $level->populateChunk($chunkX, $chunkZ, true);
     }
     return true;
 }
开发者ID:ZenaGamingsky,项目名称:PocketBox,代码行数:62,代码来源:Server.php

示例12: doSlowCleanUp

 public function doSlowCleanUp()
 {
     for ($i = 0; $i < 1024; ++$i) {
         if ($this->locationTable[$i][0] === 0 or $this->locationTable[$i][1] === 0) {
             continue;
         }
         fseek($this->filePointer, $this->locationTable[$i][0] << 12);
         $chunk = fread($this->filePointer, $this->locationTable[$i][1] << 12);
         $length = Binary::readInt(substr($chunk, 0, 4));
         if ($length <= 1) {
             $this->locationTable[$i] = [0, 0, 0];
             //Non-generated chunk, remove it from index
         }
         try {
             $chunk = zlib_decode(substr($chunk, 5));
         } catch (\Exception $e) {
             $this->locationTable[$i] = [0, 0, 0];
             //Corrupted chunk, remove it
             continue;
         }
         $chunk = chr(self::COMPRESSION_ZLIB) . zlib_encode($chunk, ZLIB_ENCODING_DEFLATE, 9);
         $chunk = Binary::writeInt(strlen($chunk)) . $chunk;
         $sectors = (int) ceil(strlen($chunk) / 4096);
         if ($sectors > $this->locationTable[$i][1]) {
             $this->locationTable[$i][0] = $this->lastSector + 1;
             $this->lastSector += $sectors;
         }
         fseek($this->filePointer, $this->locationTable[$i][0] << 12);
         fwrite($this->filePointer, str_pad($chunk, $sectors << 12, "", STR_PAD_RIGHT));
     }
     $this->writeLocationTable();
     $n = $this->cleanGarbage();
     $this->writeLocationTable();
     return $n;
 }
开发者ID:ecoron,项目名称:MinionsLandPE,代码行数:35,代码来源:RegionLoader.php

示例13: getInt

 protected function getInt()
 {
     return Binary::readInt($this->get(4));
 }
开发者ID:mattiasaxelsson,项目名称:PocketMine-MP,代码行数:4,代码来源:DataPacket.php

示例14: handle

 public function handle($address, $port, $packet)
 {
     $offset = 2;
     $packetType = ord($packet[$offset++]);
     $sessionID = Binary::readInt(substr($packet, $offset, 4));
     $offset += 4;
     $payload = substr($packet, $offset);
     switch ($packetType) {
         case self::HANDSHAKE:
             //Handshake
             $reply = chr(self::HANDSHAKE);
             $reply .= Binary::writeInt($sessionID);
             $reply .= self::getTokenString($this->token, $address) . "";
             $this->server->sendPacket($address, $port, $reply);
             break;
         case self::STATISTICS:
             //Stat
             $token = Binary::readInt(substr($payload, 0, 4));
             if ($token !== self::getTokenString($this->token, $address) and $token !== self::getTokenString($this->lastToken, $address)) {
                 break;
             }
             $reply = chr(self::STATISTICS);
             $reply .= Binary::writeInt($sessionID);
             if (strlen($payload) === 8) {
                 if ($this->timeout < microtime(true)) {
                     $this->regenerateInfo();
                 }
                 $reply .= $this->longData;
             } else {
                 $reply .= $this->server->getServerName() . "" . (($this->server->getGamemode() & 0x1) === 0 ? "SMP" : "CMP") . "" . ($this->server->getDefaultLevel() === null ? "unknown" : $this->server->getDefaultLevel()->getName()) . "" . count($this->server->getOnlinePlayers()) . "" . $this->server->getMaxPlayers() . "" . Binary::writeLShort($this->server->getPort()) . $this->server->getIp() . "";
             }
             $this->server->sendPacket($address, $port, $reply);
             break;
     }
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:35,代码来源:QueryHandler.php

示例15: decompressName

 public static function decompressName($compressed)
 {
     $int = substr($compressed, 0, 4);
     $long = substr($compressed, 4, 8);
     /** @var int $value */
     $value = Binary::readInt($int, false);
     $value <<= 32;
     $value += Binary::readLong($long, false);
     $out = "";
     for ($offset = 0; $offset <= 16; $offset++) {
         $ord = $value & 0b111111;
         if (0 <= $ord and $ord <= 9) {
             $chr = chr(ord("0") + $ord);
         } else {
             $ord -= 10;
             if ($ord <= 25) {
                 $chr = chr(ord("a") + $ord);
             } else {
                 $chr = "_";
             }
             // corrupted databases will lead to a large amount of underscores
         }
         $out = $chr . $out;
     }
     return $out;
 }
开发者ID:barnseyminesuk,项目名称:Small-ZC-Plugins,代码行数:26,代码来源:Main.php


注:本文中的pocketmine\utils\Binary::readInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。