本文整理汇总了PHP中pocketmine\Player::dataPacket方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::dataPacket方法的具体用法?PHP Player::dataPacket怎么用?PHP Player::dataPacket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\Player
的用法示例。
在下文中一共展示了Player::dataPacket方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: spawnDiscourager
public function spawnDiscourager()
{
$dir = $this->player->getDirectionVector();
if ($this->player->pitch > 45 or $this->player->pitch < -45) {
$face = 0;
// y
} else {
$face = self::$conversionTable[$this->player->getDirection()];
}
$center = $this->player->subtract($dir->multiply($this->main->getDistance()))->add(0, $this->player->eyeHeight)->floor();
$l = $this->player->getLevel();
if ($face === self::Y) {
$this->overridenBlocks = [$l->getBlock($center->add(1, 0, 1)), $l->getBlock($center->add(1, 0, 0)), $l->getBlock($center->add(1, 0, -1)), $l->getBlock($center->add(0, 0, 1)), $l->getBlock($center), $l->getBlock($center->add(0, 0, -1)), $l->getBlock($center->add(-1, 0, 1)), $l->getBlock($center->add(-1, 0, 0)), $l->getBlock($center->add(-1, 0, -1))];
} elseif ($face === self::X) {
$this->overridenBlocks = [$l->getBlock($center->add(0, 1, 1)), $l->getBlock($center->add(0, 1, 0)), $l->getBlock($center->add(0, 1, -1)), $l->getBlock($center->add(0, 0, 1)), $l->getBlock($center), $l->getBlock($center->add(0, 0, -1)), $l->getBlock($center->add(0, -1, 1)), $l->getBlock($center->add(0, -1, 0)), $l->getBlock($center->add(0, -1, -1))];
} elseif ($face === self::Z) {
$this->overridenBlocks = [$l->getBlock($center->add(1, 1, 0)), $l->getBlock($center->add(1, 0, 0)), $l->getBlock($center->add(1, -1, 0)), $l->getBlock($center->add(0, 1, 0)), $l->getBlock($center), $l->getBlock($center->add(0, -1, 0)), $l->getBlock($center->add(-1, 1, 0)), $l->getBlock($center->add(-1, 0, 0)), $l->getBlock($center->add(-1, -1, 0))];
}
foreach ($this->overridenBlocks as $b) {
$pk = new UpdateBlockPacket();
$pk->x = $b->x;
$pk->y = $b->y;
$pk->z = $b->z;
$pk->block = $this->main->getBlockType()->getId();
$pk->meta = $this->main->getBlockType()->getDamage();
$this->player->dataPacket($pk);
}
}
示例2: sendWeather
public function sendWeather(Player $p)
{
$pk1 = new LevelEventPacket();
$pk1->evid = LevelEventPacket::EVENT_STOP_RAIN;
$pk1->data = $this->strength1;
$pk2 = new LevelEventPacket();
$pk2->evid = LevelEventPacket::EVENT_STOP_THUNDER;
$pk2->data = $this->strength2;
if ($p->weatherData[0] != $this->weatherNow) {
$p->dataPacket($pk1);
$p->dataPacket($pk2);
if ($this->weatherNow == 1) {
$pk = new LevelEventPacket();
$pk->evid = LevelEventPacket::EVENT_START_RAIN;
$pk->data = $this->strength1;
$p->dataPacket($pk);
} elseif ($this->weatherNow == 2) {
$pk = new LevelEventPacket();
$pk->evid = LevelEventPacket::EVENT_START_RAIN;
$pk->data = $this->strength1;
$p->dataPacket($pk);
$pk = new LevelEventPacket();
$pk->evid = LevelEventPacket::EVENT_START_THUNDER;
$pk->data = $this->strength2;
$p->dataPacket($pk);
} elseif ($this->weatherNow == 3) {
$pk = new LevelEventPacket();
$pk->evid = LevelEventPacket::EVENT_START_THUNDER;
$pk->data = $this->strength2;
$p->dataPacket($pk);
}
$p->weatherData = [$this->weatherNow, $this->strength1, $this->strength2];
}
}
示例3: invis
private function invis()
{
$pk = new SetEntityDataPacket();
$pk->eid = $this->eid;
$flags = 1 << Entity::DATA_FLAG_INVISIBLE;
$pk->data = [Entity::DATA_FLAGS => [Entity::DATA_TYPE_INT, $flags]];
$this->player->dataPacket($pk);
$pk = new SetEntityDataPacket();
$pk->eid = $this->eid;
$pk->data = [Entity::DATA_SHOW_NAMETAG => [Entity::DATA_TYPE_BYTE, 0]];
$this->player->dataPacket($pk);
}
示例4: illuminate
public function illuminate(Player $player)
{
if ($player == null) {
return;
}
if ($player->getLevel()->getBlockIdAt($player->x, $player->y + 1, $player->z) == Block::AIR) {
$this->pk->x = $player->x;
$this->pk->y = $player->y + 1;
$this->pk->z = $player->z;
$this->pk->block = Item::TORCH;
$this->pk->meta = 0;
$player->dataPacket($this->pk);
$this->pk->block = Item::AIR;
$player->dataPacket($this->pk);
}
}
示例5: onClose
public function onClose(Player $who)
{
$pk = new ContainerClosePacket();
$pk->windowid = $who->getWindowId($this);
$who->dataPacket($pk);
parent::onClose($who);
}
示例6: spawnTo
public function spawnTo(Player $player)
{
if ($player !== $this and !isset($this->hasSpawned[$player->getLoaderId()])) {
$this->hasSpawned[$player->getLoaderId()] = $player;
$uuid = $this->getUniqueId();
$entityId = $this->getId();
$pk = new AddPlayerPacket();
$pk->uuid = $uuid;
$pk->username = "";
$pk->eid = $entityId;
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->yaw = $this->yaw;
$pk->pitch = $this->pitch;
$pk->item = $this->getInventory()->getItemInHand();
$pk->metadata = [2 => [4, str_ireplace("{name}", $player->getName(), str_ireplace("{display_name}", $player->getDisplayName(), $player->hasPermission("slapper.seeId") ? $this->getDataProperty(2) . "\n" . \pocketmine\utils\TextFormat::GREEN . "Entity ID: " . $entityId : $this->getDataProperty(2)))], 3 => [0, $this->getDataProperty(3)], 15 => [0, 1]];
$player->dataPacket($pk);
$this->inventory->sendArmorContents($player);
$add = new PlayerListPacket();
$add->type = 0;
$add->entries[] = [$uuid, $entityId, isset($this->namedtag->MenuName) ? $this->namedtag["MenuName"] : "", $this->skinName, $this->skin];
$player->dataPacket($add);
if ($this->namedtag["MenuName"] === "") {
$remove = new PlayerListPacket();
$remove->type = 1;
$remove->entries[] = [$uuid];
$player->dataPacket($remove);
}
}
}
示例7: sendAll
public function sendAll()
{
$pk = new UpdateAttributesPacket();
$pk->entityId = 0;
$pk->entries = $this->attributes;
$this->player->dataPacket($pk);
}
示例8: onClose
public function onClose(Player $who)
{
$pk = new ContainerClosePacket();
$pk->windowid = $who->getWindowId($this);
$who->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
parent::onClose($who);
}
示例9: sendData
private function sendData($data)
{
$pk = new SetEntityDataPacket();
$pk->eid = $this->eid();
$pk->metadata = $data === null ? $this->metadata : $data;
$this->player->dataPacket($pk);
}
示例10: spawnTo
public function spawnTo(Player $player)
{
if ($player !== $this and !isset($this->hasSpawned[$player->getLoaderId()])) {
$this->hasSpawned[$player->getLoaderId()] = $player;
$pk = new AddPlayerPacket();
$pk->uuid = $this->getUniqueId();
$pk->username = $this->getName();
$pk->eid = $this->getId();
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->speedX = 0;
$pk->speedY = 0;
$pk->speedZ = 0;
$pk->yaw = $this->yaw;
$pk->pitch = $this->pitch;
$item = $this->getInventory()->getItemInHand();
$pk->item = $item;
if ($player->hasPermission("slapper.seeownskin")) {
$pk->skin = $player->getSkinData();
$pk->slim = $player->isSkinSlim();
} else {
$pk->skin = $this->skin;
$pk->slim = $this->isSlim;
}
$pk->metadata = [2 => [4, $this->getDataProperty(2)], 3 => [0, $this->getDataProperty(3)], 15 => [0, 1]];
$player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));
$this->inventory->sendArmorContents($player);
}
}
示例11: spawnTo
public function spawnTo(Player $player)
{
$pk = new AddMobPacket();
$pk->eid = $this->getID();
$pk->type = Villager::NETWORK_ID;
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->yaw = $this->yaw;
$pk->pitch = $this->pitch;
$pk->metadata = $this->getData();
$player->dataPacket($pk);
$pk = new SetEntityMotionPacket();
$pk->entities = [[$this->getID(), $this->motionX, $this->motionY, $this->motionZ]];
$player->dataPacket($pk);
parent::spawnTo($player);
}
示例12: onActivate
public function onActivate(Item $item, Player $player = null)
{
$time = $this->getLevel()->getTime() % Level::TIME_FULL;
$isNight = ($time >= Level::TIME_NIGHT and $time < Level::TIME_SUNRISE);
if ($player instanceof Player and !$isNight) {
$pk = new ChatPacket();
$pk->message = "You can only sleep at night";
$player->dataPacket($pk);
return true;
}
$blockNorth = $this->getSide(2);
//Gets the blocks around them
$blockSouth = $this->getSide(3);
$blockEast = $this->getSide(5);
$blockWest = $this->getSide(4);
if (($this->meta & 0x8) === 0x8) {
//This is the Top part of bed
$b = $this;
} else {
//Bottom Part of Bed
if ($blockNorth->getId() === $this->id and ($blockNorth->meta & 0x8) === 0x8) {
$b = $blockNorth;
} elseif ($blockSouth->getId() === $this->id and ($blockSouth->meta & 0x8) === 0x8) {
$b = $blockSouth;
} elseif ($blockEast->getId() === $this->id and ($blockEast->meta & 0x8) === 0x8) {
$b = $blockEast;
} elseif ($blockWest->getId() === $this->id and ($blockWest->meta & 0x8) === 0x8) {
$b = $blockWest;
} else {
if ($player instanceof Player) {
$pk = new ChatPacket();
$pk->message = "This bed is incomplete";
$player->dataPacket($pk);
}
return true;
}
}
if ($player instanceof Player and $player->sleepOn($b) === false) {
$pk = new ChatPacket();
$pk->message = "This bed is occupied";
$player->dataPacket($pk);
}
return true;
}
示例13: spawnTo
public function spawnTo(Player $player)
{
$pk = new SpawnExperienceOrbPacket();
$pk->eid = $this->getId();
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->count = $this->getAmount();
$player->dataPacket($pk);
parent::spawnTo($player);
}
示例14: send
public function send()
{
$pk = new UpdateAttributesPacket();
$pk->maxValue = $this->getMaxValue();
$pk->minValue = $this->getMinValue();
$pk->value = $this->currentValue;
$pk->name = $this->getName();
$pk->entityId = 0;
$pk->encode();
$this->player->dataPacket($pk);
}
示例15: spawnTo
public function spawnTo(Player $player)
{
$pk = new AddPaintingPacket();
$pk->eid = $this->getId();
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->direction = $this->getDirection();
$pk->title = $this->motive;
$player->dataPacket($pk);
parent::spawnTo($player);
}