本文整理匯總了PHP中pocketmine\network\protocol\BatchPacket類的典型用法代碼示例。如果您正苦於以下問題:PHP BatchPacket類的具體用法?PHP BatchPacket怎麽用?PHP BatchPacket使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了BatchPacket類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: broadcastPacketsCallback
public function broadcastPacketsCallback($data, array $identifiers)
{
$pk = new BatchPacket();
$pk->payload = $data;
$pk->encode();
$pk->isEncoded = true;
foreach ($identifiers as $i) {
if (isset($this->players[$i])) {
$this->players[$i]->dataPacket($pk);
}
}
}
示例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;
}
示例3: 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);
}
}
}
}
示例4: batchDataPacket
/**
* Batch a Data packet
*
* @param DataPacket $packet
*
* @return bool
*/
public function batchDataPacket(DataPacket $packet)
{
$str = "";
if ($packet instanceof DataPacket) {
if (!$packet->isEncoded) {
$packet->encode();
}
$str .= Binary::writeInt(strlen($packet->buffer)) . $packet->buffer;
} else {
$str .= Binary::writeInt(strlen($packet)) . $packet;
}
$pk = new BatchPacket();
$pk->payload = zlib_encode($str, ZLIB_ENCODING_DEFLATE, 7);
$pk->encode();
$pk->isEncoded = true;
$this->dataPacket($pk);
}
示例5: 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;
}
示例6: sendBatchedChunk
public function sendBatchedChunk($x, $z, $payload)
{
$this->usedChunks[Level::chunkHash($x, $z)] = true;
$this->chunkLoadCount++;
$bt = new BatchPacket();
$bt->payload = $payload;
$bt->encode();
$bt->isEncoded = true;
$this->dataPacket($bt);
}
示例7: 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);
}
}
}
}
}