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


PHP Player::directDataPacket方法代码示例

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


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

示例1: openChest

 public static function openChest(Block $chest, Player $player)
 {
     if ($chest->getId() === Item::CHEST) {
         if ($player->gamemode === Player::CREATIVE) {
             $player->sendMessage("[HG] You are in creative Mode");
             return;
         }
         if (!$player->isOp()) {
             $pk = new ContainerOpenPacket();
             $pk->windowid = $player->getWindowId($player->getInventory());
             $pk->type = InventoryType::CHEST;
             $pk->slots = $player->getInventory()->getSize();
             $pk->x = $chest->x;
             $pk->y = $chest->y;
             $pk->z = $chest->z;
             $pk->encode();
             $player->directDataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
             if ($player->getInventory() != null) {
                 $player->getInventory()->sendContents($player);
             }
             $player->sendTip("chest open!");
         }
     }
 }
开发者ID:robozeri,项目名称:SG,代码行数:24,代码来源:PlayerHelper.php

示例2: removeWaterField

 public function removeWaterField(Player $player)
 {
     $level = $player->getLevel();
     $pk = new UpdateBlockPacket();
     if (isset($this->waterField[$player->getName()]["pos"])) {
         $pos = explode(":", $this->waterField[$player->getName()]["pos"]);
         $sides = [[1, 1], [1, 0], [1, 1], [0, -1], [0, 0], [0, 1], [-1, -1], [-1, 0], [-1, 0]];
         foreach ($sides as $side) {
             $downId = $level->getBlockIdAt($pos[0] + $side[0], $pos[2], $pos[1] + $side[1]);
             $downDmg = $level->getBlockDataAt($pos[0] + $side[0], $pos[2], $pos[1] + $side[1]);
             $pk->records[] = [$pos[0] + $side[0], $pos[1] + $side[1], $pos[2], $downId, $downDmg, UpdateBlockPacket::FLAG_NONE];
         }
         $player->directDataPacket($pk->setChannel(Network::CHANNEL_BLOCKS));
         unset($this->waterField[$player->getName()]["pos"]);
     }
 }
开发者ID:JiangsNetworkAlpha,项目名称:FlyingBoats,代码行数:16,代码来源:EventListener.php

示例3: setBlockPacket

 public function setBlockPacket(Player $player, $x, $y, $z, $block, $meta = 0)
 {
     $this->updatePk->x = $x;
     $this->updatePk->y = $y;
     $this->updatePk->z = $z;
     $this->updatePk->block = $block;
     $this->updatePk->meta = $meta;
     $player->directDataPacket($this->updatePk);
 }
开发者ID:EmreTr1,项目名称:rtr,代码行数:9,代码来源:HungerGames.php

示例4: spawnPlayer

 public function spawnPlayer($eid, Player $p, $pos, $userName, $itemId, $slots, $mx = 0, $my = 290, $mz = 0)
 {
     $pk = new AddPlayerPacket();
     $pk->clientID = rand(101, 9999);
     $pk->username = $userName;
     $pk->eid = $eid;
     $pk->x = $pos->x + 0.5;
     $pk->y = $pos->y;
     $pk->z = $pos->z + 0.5;
     $pk->yaw = $p->yaw;
     $pk->pitch = $p->pitch;
     $pk->unknown1 = 0;
     $pk->unknown2 = 0;
     $pk->item = $itemId;
     $pk->meta = 0;
     $pk->metadata = [];
     $pk->skin = $p->getSkinData();
     $pk->encode();
     $p->directDataPacket($pk);
     Server::broadcastPacket($p->getViewers(), $pk);
     $p->addEntityMotion($eid, 0, 290, 0);
     if ($slots != null) {
         $pk = new PlayerArmorEquipmentPacket();
         $pk->eid = $eid;
         $pk->slots = $slots;
         $pk->encode();
         $pk->isEncoded = true;
         $p->directDataPacket($pk);
         Server::broadcastPacket($p->getViewers(), $pk);
     }
 }
开发者ID:robozeri,项目名称:SG,代码行数:31,代码来源:StatueBuilder.php


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