本文整理汇总了PHP中pocketmine\utils\Binary::readLInt方法的典型用法代码示例。如果您正苦于以下问题:PHP Binary::readLInt方法的具体用法?PHP Binary::readLInt怎么用?PHP Binary::readLInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\utils\Binary
的用法示例。
在下文中一共展示了Binary::readLInt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: readPacket
private function readPacket($client, &$size, &$requestID, &$packetType, &$payload)
{
socket_set_nonblock($client);
$d = socket_read($client, 4);
if ($this->stop === true) {
return false;
} elseif ($d === false) {
return null;
} elseif ($d === "" or strlen($d) < 4) {
return false;
}
socket_set_block($client);
$size = Binary::readLInt($d);
if ($size < 0 or $size > 65535) {
return false;
}
$requestID = Binary::readLInt(socket_read($client, 4));
$packetType = Binary::readLInt(socket_read($client, 4));
$payload = rtrim(socket_read($client, $size + 2));
//Strip two null bytes
return true;
}
示例2: getLInt
public function getLInt()
{
return Binary::readLInt($this->get(4));
}
示例3: parseChunk
public function parseChunk($X, $Z)
{
$X = (int) $X;
$Z = (int) $Z;
$offset = $this->getOffset($X, $Z);
$len = Binary::readLInt(substr($this->raw, $offset, 4));
$offset += 4;
$chunk = [0 => [], 1 => [], 2 => [], 3 => []];
foreach ($chunk as $section => &$data) {
$l = $section === 0 ? 128 : 64;
for ($i = 0; $i < 256; ++$i) {
$data[$i] = substr($this->raw, $offset, $l);
$offset += $l;
}
}
return $chunk;
}
示例4: getInt
public function getInt()
{
return $this->endianness === self::BIG_ENDIAN ? Binary::readInt($this->get(4)) : Binary::readLInt($this->get(4));
}
示例5: fromBinary
/**
* @param string $data
* @param LevelProvider $provider
*
* @return Chunk
*/
public static function fromBinary($data, LevelProvider $provider = null)
{
try {
$chunkX = Binary::readLInt(substr($data, 0, 4));
$chunkZ = Binary::readLInt(substr($data, 4, 4));
$chunkData = substr($data, 8, -1);
$flags = ord(substr($data, -1));
$entities = null;
$tiles = null;
if ($provider instanceof LevelDB) {
$nbt = new NBT(NBT::LITTLE_ENDIAN);
$entityData = $provider->getDatabase()->get(substr($data, 0, 8) . "2");
if ($entityData !== false and strlen($entityData) > 0) {
$nbt->read($entityData, true);
$entities = $nbt->getData();
if (!is_array($entities)) {
$entities = [$entities];
}
}
$tileData = $provider->getDatabase()->get(substr($data, 0, 8) . "1");
if ($tileData !== false and strlen($tileData) > 0) {
$nbt->read($tileData, true);
$tiles = $nbt->getData();
if (!is_array($tiles)) {
$tiles = [$tiles];
}
}
}
$chunk = new Chunk($provider instanceof LevelProvider ? $provider : LevelDB::class, $chunkX, $chunkZ, $chunkData, $entities, $tiles);
if ($flags & 0x1) {
$chunk->setGenerated();
}
if ($flags & 0x2) {
$chunk->setPopulated();
}
return $chunk;
} catch (\Exception $e) {
return null;
}
}
示例6: getInt
public function getInt(bool $network = false)
{
if ($network === true) {
return Binary::readVarInt($this);
}
return $this->endianness === self::BIG_ENDIAN ? Binary::readInt($this->get(4)) : Binary::readLInt($this->get(4));
}