本文整理汇总了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!");
}
}
}
示例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"]);
}
}
示例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);
}
示例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);
}
}