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


PHP utils\Binary类代码示例

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


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

示例1: 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

示例2: __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

示例3: encode

 public function encode()
 {
     $this->reset();
     $this->buffer .= Binary::writeLong($this->eid);
     $meta = Binary::writeMetadata($this->metadata);
     $this->buffer .= $meta;
 }
开发者ID:Edwardthedog2,项目名称:Steadfast2,代码行数:7,代码来源:SetEntityDataPacket.php

示例4: __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

示例5: encode

 public function encode()
 {
     $this->reset();
     $this->buffer .= Binary::writeLong($this->from);
     $this->buffer .= Binary::writeLong($this->to);
     $this->buffer .= \chr($this->type);
 }
开发者ID:Edwardthedog2,项目名称:Steadfast2,代码行数:7,代码来源:SetEntityLinkPacket.php

示例6: decode

 public function decode()
 {
     $this->eid = Binary::readLong($this->get(8));
     $this->x = \PHP_INT_SIZE === 8 ? \unpack("N", $this->get(4))[1] << 32 >> 32 : \unpack("N", $this->get(4))[1];
     $this->z = \PHP_INT_SIZE === 8 ? \unpack("N", $this->get(4))[1] << 32 >> 32 : \unpack("N", $this->get(4))[1];
     $this->y = \ord($this->get(1));
 }
开发者ID:Edwardthedog2,项目名称:Steadfast2,代码行数:7,代码来源:RemoveBlockPacket.php

示例7: 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

示例8: decode

 public function decode()
 {
     $this->eid = Binary::readLong($this->get(8));
     $this->x = \unpack("N", $this->get(4))[1];
     $this->z = \unpack("N", $this->get(4))[1];
     $this->y = \ord($this->get(1));
 }
开发者ID:xpyctum,项目名称:PocketMinePlusPlus,代码行数:7,代码来源:RemoveBlockPacket__32bit.php

示例9: decode

 public function decode()
 {
     $this->eid = Binary::readLong($this->get(8));
     $this->item = $this->getSlot();
     $this->slot = \ord($this->get(1));
     $this->selectedSlot = \ord($this->get(1));
 }
开发者ID:ken77731,项目名称:PocketMine-0.13.0,代码行数:7,代码来源:MobEquipmentPacket__64bit.php

示例10: encode

 public function encode()
 {
     $this->buffer = \chr(self::NETWORK_ID);
     $this->offset = 0;
     $this->buffer .= Binary::writeLong($this->target);
     $this->buffer .= Binary::writeLong($this->eid);
 }
开发者ID:kazuemon,项目名称:NIGHTMARE,代码行数:7,代码来源:TakeItemEntityPacket.php

示例11: encode

 public function encode()
 {
     $this->buffer = \chr(self::NETWORK_ID);
     $this->offset = 0;
     $this->buffer .= Binary::writeLong($this->eid);
     $this->putUUID($this->clientId);
 }
开发者ID:kazuemon,项目名称:NIGHTMARE,代码行数:7,代码来源:RemovePlayerPacket.php

示例12: encode

 public function encode()
 {
     $this->reset();
     $this->putLong($this->eid);
     $meta = Binary::writeMetadata($this->metadata);
     $this->put($meta);
 }
开发者ID:Cybertechpp,项目名称:Steadfast2,代码行数:7,代码来源:SetEntityDataPacket.php

示例13: onPkt

 public function onPkt(DataPacketReceiveEvent $e)
 {
     if ($e->getPacket()->pid() !== 0x0) {
         return;
     }
     $this->lastPing[strtolower($e->getPlayer()->getName())] = Binary::readLong($e->getPacket()->buffer) / 1000.0;
 }
开发者ID:AvivShopen,项目名称:bad-plugins,代码行数:7,代码来源:Main.php

示例14: decode

 public function decode()
 {
     $this->eid = Binary::readLong($this->get(8));
     $this->slots[0] = $this->getSlot();
     $this->slots[1] = $this->getSlot();
     $this->slots[2] = $this->getSlot();
     $this->slots[3] = $this->getSlot();
 }
开发者ID:xpyctum,项目名称:PocketMinePlusPlus,代码行数:8,代码来源:MobArmorEquipmentPacket__64bit.php

示例15: encode

 public function encode()
 {
     $this->buffer = \chr(self::NETWORK_ID);
     $this->offset = 0;
     $this->buffer .= Binary::writeLong($this->from);
     $this->buffer .= Binary::writeLong($this->to);
     $this->buffer .= \chr($this->type);
 }
开发者ID:xpyctum,项目名称:PocketMinePlusPlus,代码行数:8,代码来源:SetEntityLinkPacket.php


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