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


PHP protocol\FullChunkDataPacket类代码示例

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


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

示例1: sendChunk

 public function sendChunk($x, $z, $payload, $ordering = FullChunkDataPacket::ORDER_COLUMNS)
 {
     if ($this->connected === false) {
         return;
     }
     $this->usedChunks[Level::chunkHash($x, $z)] = true;
     $this->chunkLoadCount++;
     $pk = new FullChunkDataPacket();
     $pk->chunkX = $x;
     $pk->chunkZ = $z;
     $pk->order = $ordering;
     $pk->data = $payload;
     $pk->encode();
     $bt = new BatchPacket();
     $str = $pk->buffer;
     $bt->payload = zlib_encode($str, ZLIB_ENCODING_DEFLATE, 7);
     $bt->encode();
     $bt->isEncoded = true;
     $this->dataPacket($bt);
     if ($this->spawned) {
         foreach ($this->level->getChunkEntities($x, $z) as $entity) {
             if ($entity !== $this and !$entity->closed and !$entity->dead) {
                 $entity->spawnTo($this);
             }
         }
     }
 }
开发者ID:ZenaGamingsky,项目名称:Steadfast2,代码行数:27,代码来源:Player.php

示例2: getChunkCacheFromData

 /**
  * @param $chunkX
  * @param $chunkZ
  * @param $payload
  *
  * @return DataPacket
  */
 public static function getChunkCacheFromData($chunkX, $chunkZ, $payload, $ordering = FullChunkDataPacket::ORDER_COLUMNS)
 {
     $pk = new FullChunkDataPacket();
     $pk->chunkX = $chunkX;
     $pk->chunkZ = $chunkZ;
     $pk->order = $ordering;
     $pk->data = $payload;
     $pk->encode();
     $batch = new BatchPacket();
     $batch->payload = zlib_encode(Binary::writeInt(strlen($pk->getBuffer())) . $pk->getBuffer(), ZLIB_ENCODING_DEFLATE, Server::getInstance()->networkCompressionLevel);
     $batch->encode();
     $batch->isEncoded = true;
     return $batch;
 }
开发者ID:NewDelion,项目名称:PocketMine-0.13.x,代码行数:21,代码来源:Player.php

示例3: saveChunkToDisk

 public function saveChunkToDisk($x, $z, $payload, $ordering = FullChunkDataPacket::ORDER_COLUMNS)
 {
     // When the payload of the chunk has been calculated it, save it if possible to save future CPU cycles
     /** @var Player $player */
     if (file_exists("chunk_cache/" . $this->getName() . "/" . $x . "_" . $z . ".dat")) {
         $this->loadChunkFromDisk($x, $z);
         return true;
     }
     $pk = new FullChunkDataPacket();
     $pk->chunkX = $x;
     $pk->chunkZ = $z;
     $pk->order = $ordering;
     $pk->data = $payload;
     $pk->encode();
     // all chunks are zlib_encoded, level is arbitrary but 6 is a good match between device CPU power needed
     // and bandwidth
     $data = zlib_encode(Binary::writeInt(strlen($pk->buffer)) . $pk->buffer, ZLIB_ENCODING_DEFLATE, 6);
     $this->chunkCache[$x . ":" . $z] = $data;
     if (!$this->server->getKatana()->getProperty("cache.save-to-disk", true)) {
         return true;
     }
     file_put_contents("chunk_cache/" . $this->getName() . "/" . $x . "_" . $z . ".dat", $data);
     return true;
 }
开发者ID:AbelGamerC,项目名称:Katana,代码行数:24,代码来源:Level.php

示例4: getChunkCacheFromData

 /**
  * @param $chunkX
  * @param $chunkZ
  * @param $payload
  *
  * @return DataPacket
  */
 public static function getChunkCacheFromData($chunkX, $chunkZ, $payload)
 {
     $pk = new FullChunkDataPacket();
     $pk->chunkX = $chunkX;
     $pk->chunkZ = $chunkZ;
     $pk->data = $payload;
     $pk->encode();
     $batch = new BatchPacket();
     $batch->payload = zlib_encode($pk->getBuffer(), ZLIB_ENCODING_DEFLATE, Server::getInstance()->networkCompressionLevel);
     $batch->setChannel(Network::CHANNEL_WORLD_CHUNKS);
     $batch->encode();
     $batch->isEncoded = true;
     return $batch;
 }
开发者ID:richarrj,项目名称:PocketMine-MP,代码行数:21,代码来源:Player.php

示例5: requestChunkTask

 public function requestChunkTask($x, $z)
 {
     $chunk = $this->getChunk($x, $z, false);
     if (!$chunk instanceof Chunk) {
         throw new ChunkException("Invalid Chunk sent");
     }
     $tiles = "";
     $nbt = new NBT(NBT::LITTLE_ENDIAN);
     foreach ($chunk->getTiles() as $tile) {
         if ($tile instanceof Spawnable) {
             $nbt->setData($tile->getSpawnCompound());
             $tiles .= $nbt->write();
         }
     }
     $extraData = new BinaryStream();
     $extraData->putLInt(count($chunk->getBlockExtraDataArray()));
     foreach ($chunk->getBlockExtraDataArray() as $key => $value) {
         $extraData->putLInt($key);
         $extraData->putLShort($value);
     }
     $ordered = $chunk->getBlockIdArray() . $chunk->getBlockDataArray() . $chunk->getBlockSkyLightArray() . $chunk->getBlockLightArray() . pack("C*", ...$chunk->getHeightMapArray()) . pack("N*", ...$chunk->getBiomeColorArray()) . $extraData->getBuffer() . $tiles;
     $pk = new FullChunkDataPacket();
     $pk->chunkX = $x;
     $pk->chunkZ = $z;
     $pk->order = FullChunkDataPacket::ORDER_COLUMNS;
     $pk->data = $ordered;
     $pk->encode();
     $str = "";
     $str .= Binary::writeInt(strlen($pk->buffer)) . $pk->buffer;
     $this->getLevel()->chunkRequestCallback($x, $z, zlib_encode($str, ZLIB_ENCODING_DEFLATE, 7));
     return null;
 }
开发者ID:TylerAndrew,项目名称:Steadfast2,代码行数:32,代码来源:McRegion.php

示例6: sendChunk

 public function sendChunk($x, $z, $payload)
 {
     if ($this->connected === false) {
         return;
     }
     $this->usedChunks[Level::chunkHash($x, $z)] = true;
     $this->chunkLoadCount++;
     $pk = new FullChunkDataPacket();
     $pk->chunkX = $x;
     $pk->chunkZ = $z;
     $pk->data = $payload;
     $this->batchDataPacket($pk->setChannel(Network::CHANNEL_WORLD_CHUNKS));
     if ($this->spawned) {
         foreach ($this->level->getChunkEntities($x, $z) as $entity) {
             if ($entity !== $this and !$entity->closed and !$entity->dead) {
                 $entity->spawnTo($this);
             }
         }
     }
 }
开发者ID:TylerGames,项目名称:PocketMine-MP,代码行数:20,代码来源:Player.php

示例7: sendChunk

 public function sendChunk($x, $z, $payload)
 {
     if ($this->connected === \false) {
         return;
     }
     $this->usedChunks[\PHP_INT_SIZE === 8 ? ($x & 0xffffffff) << 32 | $z & 0xffffffff : $x . ":" . $z] = \true;
     $this->chunkLoadCount++;
     $pk = new FullChunkDataPacket();
     $pk->chunkX = $x;
     $pk->chunkZ = $z;
     $pk->data = $payload;
     $this->batchDataPacket($pk->setChannel(Network::CHANNEL_WORLD_CHUNKS));
     if ($this->spawned) {
         foreach ($this->level->getChunkEntities($x, $z) as $entity) {
             if ($entity !== $this and !$entity->closed and !$entity->dead) {
                 $entity->spawnTo($this);
             }
         }
     }
 }
开发者ID:Edwardthedog2,项目名称:Steadfast2,代码行数:20,代码来源:Player.php

示例8: sendChunks

 public function sendChunks($data = array())
 {
     if ($this->connected === \false) {
         return;
     }
     $bt = new BatchPacket();
     $str = "";
     foreach ($data as $set) {
         $x = $set["x"];
         $z = $set["z"];
         $payload = $set["payload"];
         $this->usedChunks[Level::chunkHash($x, $z)] = true;
         $this->chunkLoadCount++;
         $pk = new FullChunkDataPacket();
         $pk->chunkX = $x;
         $pk->chunkZ = $z;
         $pk->data = $payload;
         $pk->setChannel(Network::CHANNEL_WORLD_CHUNKS);
         $pk->encode();
         $str .= $pk->buffer;
     }
     $bt->setChannel($this->spawned ? Network::CHANNEL_WORLD_CHUNKS : Network::CHANNEL_PRIORITY);
     $bt->payload = zlib_encode($str, ZLIB_ENCODING_DEFLATE, 6);
     $bt->encode();
     $bt->isEncoded = true;
     $this->dataPacket($bt);
     foreach ($data as $set) {
         $x = $set["x"];
         $z = $set["z"];
         $payload = $set["payload"];
         if ($this->spawned) {
             foreach ($this->level->getChunkEntities($x, $z) as $entity) {
                 if ($entity !== $this and !$entity->closed and !$entity->dead) {
                     $entity->spawnTo($this);
                 }
             }
         }
     }
 }
开发者ID:xHFx,项目名称:Steadfast2,代码行数:39,代码来源:Player.php


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