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


PHP Server::broadcastPacket方法代码示例

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


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

示例1: attack

 public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC)
 {
     if ($this->attackTime > 0) {
         $lastCause = $this->getLastDamageCause();
         if ($lastCause instanceof EntityDamageEvent and $lastCause->getDamage() >= $damage) {
             return;
         }
     }
     $pk = new EntityEventPacket();
     $pk->eid = $this->getID();
     $pk->event = 2;
     //Ouch!
     Server::broadcastPacket($this->hasSpawned, $pk);
     $this->setLastDamageCause($source);
     $motion = new Vector3(0, 0, 0);
     if ($source instanceof EntityDamageByEntityEvent) {
         $e = $source->getDamager();
         $deltaX = $this->x - $e->x;
         $deltaZ = $this->z - $e->z;
         $yaw = atan2($deltaX, $deltaZ);
         $motion->x = sin($yaw) * 0.5;
         $motion->z = cos($yaw) * 0.5;
     }
     $this->setMotion($motion);
     $this->setHealth($this->getHealth() - $damage);
     $this->attackTime = 10;
     //0.5 seconds cooldown
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:28,代码来源:Living.php

示例2: execute

 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     if (count($args) !== 1) {
         $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
         return false;
     }
     $difficulty = Server::getDifficultyFromString($args[0]);
     if ($sender->getServer()->isHardcore()) {
         $difficulty = 3;
     }
     if ($difficulty !== -1) {
         $sender->getServer()->setConfigInt("difficulty", $difficulty);
         $pk = new SetDifficultyPacket();
         $pk->difficulty = $sender->getServer()->getDifficulty();
         Server::broadcastPacket($sender->getServer()->getOnlinePlayers(), $pk);
         Command::broadcastCommandMessage($sender, new TranslationContainer("commands.difficulty.success", [$difficulty]));
     } else {
         $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
         return false;
     }
     return true;
 }
开发者ID:NewDelion,项目名称:PocketMine-0.13.x,代码行数:25,代码来源:DifficultyCommand.php

示例3: explode

 public function explode(Position $pos)
 {
     $aabb = new AxisAlignedBB($pos->getX() - self::RANGE, $pos->getY() - self::RANGE, $pos->getZ() - self::RANGE, $pos->getX() + self::RANGE, $pos->getY() + self::RANGE, $pos->getZ() + self::RANGE);
     $nearbyEntities = $this->getPlayer()->getLevel()->getNearbyEntities($aabb, null);
     $pk = new ExplodePacket();
     $pk->x = $pos->x;
     $pk->y = $pos->y;
     $pk->z = $pos->z;
     $pk->radius = 10;
     $pk->records = [new Vector3($pos->x, $pos->y, $pos->z)];
     Server::broadcastPacket($this->getPlayer()->getLevel()->getChunkPlayers($pos->x >> 4, $pos->z >> 4), $pk->setChannel(Network::CHANNEL_BLOCKS));
     foreach ($nearbyEntities as $entity) {
         if (!$entity instanceof Player) {
             continue;
         }
         if ($this->getPlugin()->isEnemy($this->getPlayer()->getName(), $entity->getName())) {
             //cause : 15, damage : 15, knockback : 5
             $event = new EntityDamageByEntityEvent($this->getPlayer(), $entity, 15, 15, 5);
             $entity->attack($event->getFinalDamage(), $event);
         }
     }
     for ($i = 0; $i < 100; $i++) {
         $this->getPlayer()->getLevel()->addParticle(new SmokeParticle(new Vector3($pos->x + mt_rand(-self::RANGE, self::RANGE), $pos->y + mt_rand(-self::RANGE, self::RANGE), $pos->z + mt_rand(-self::RANGE, self::RANGE))));
     }
 }
开发者ID:EmreTr1,项目名称:MineCombat,代码行数:25,代码来源:Bazooka.php

示例4: onCancel

 public function onCancel()
 {
     $flags = (int) $this->target->getDataProperty(Player::DATA_FLAGS);
     $dataProperty = [Player::DATA_FLAGS => [Player::DATA_TYPE_BYTE, $flags]];
     $pk = new SetEntityDataPacket();
     $pk->eid = $this->target->getId();
     $pk->metadata = $dataProperty;
     Server::broadcastPacket($this->target->getLevel()->getPlayers(), $pk);
 }
开发者ID:HelloWorld017,项目名称:ToAruArcher,代码行数:9,代码来源:SafeBurnThread.php

示例5: setFlaming

 public function setFlaming(Player $target)
 {
     $flags = (int) $target->getDataProperty(Player::DATA_FLAGS);
     $flags ^= 1 << Player::DATA_FLAG_ONFIRE;
     $dataProperty = [Player::DATA_FLAGS => [Player::DATA_TYPE_BYTE, $flags]];
     $pk = new SetEntityDataPacket();
     $pk->eid = $target->getId();
     $pk->metadata = $dataProperty;
     Server::broadcastPacket($this->getPlayer()->getLevel()->getPlayers(), $pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
 }
开发者ID:EmreTr1,项目名称:MineCombat,代码行数:10,代码来源:FlameThrower.php

示例6: onCancel

 public function onCancel()
 {
     $flags = (int) $this->target->getDataProperty(Player::DATA_FLAGS);
     $dataProperty = [Player::DATA_FLAGS => [Player::DATA_TYPE_BYTE, $flags]];
     $pk = new SetEntityDataPacket();
     $pk->eid = $this->target->getId();
     $pk->metadata = $dataProperty;
     Server::broadcastPacket($this->target->getLevel()->getPlayers(), $pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
     unset(FlameThrower::$tasks[$this->target->getName()]);
 }
开发者ID:EmreTr1,项目名称:MineCombat,代码行数:10,代码来源:FlameTask.php

示例7: doorSound

 public function doorSound(Vector3 $pos)
 {
     $pk = new LevelEventPacket();
     $pk->x = $pos->x;
     $pk->y = $pos->y;
     $pk->z = $pos->z;
     $pk->evid = 1003;
     $pk->data = 0;
     Server::broadcastPacket($this->getServer()->getOnlinePlayers(), $pk);
 }
开发者ID:EmreTr1,项目名称:rtr,代码行数:10,代码来源:automaticDoor.php

示例8: onShoot

 public function onShoot()
 {
     $this->lastShoot = microtime(true);
     $pk = new ExplodePacket();
     $pk->x = $this->player->getX();
     $pk->y = $this->player->getY();
     $pk->z = $this->player->getZ();
     $pk->radius = 10;
     $pk->records = [new Vector3($this->player->getX(), $this->player->getY() + 1.62, $this->player->getZ())];
     Server::broadcastPacket($this->getPlayer()->getLevel()->getChunkPlayers($this->player->getX() >> 4, $this->player->getZ() >> 4), $pk->setChannel(Network::CHANNEL_BLOCKS));
 }
开发者ID:EmreTr1,项目名称:MineCombat,代码行数:11,代码来源:Shotgun.php

示例9: setHeldItemIndex

 public function setHeldItemIndex($index)
 {
     if ($index >= 0 and $index < $this->getHotbarSize()) {
         $this->itemInHandIndex = $index;
         $item = $this->getItemInHand();
         $pk = new PlayerEquipmentPacket();
         $pk->eid = $this->getHolder()->getId();
         $pk->item = $item->getId();
         $pk->meta = $item->getDamage();
         $pk->slot = $this->getHeldItemIndex();
         Server::broadcastPacket($this->getHolder()->getViewers(), $pk);
     }
 }
开发者ID:rryy,项目名称:PocketMine-MP,代码行数:13,代码来源:PlayerInventory.php

示例10: onClose

 public function onClose(Player $who)
 {
     if (count($this->getViewers()) === 1) {
         $pk = new TileEventPacket();
         $pk->x = $this->getHolder()->getX();
         $pk->y = $this->getHolder()->getY();
         $pk->z = $this->getHolder()->getZ();
         $pk->case1 = 1;
         $pk->case2 = 0;
         Server::broadcastPacket($this->getHolder()->getLevel()->getPlayers(), $pk);
     }
     parent::onClose($who);
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:13,代码来源:ChestInventory.php

示例11: onClose

 public function onClose(Player $who)
 {
     if (count($this->getViewers()) === 1) {
         $pk = new TileEventPacket();
         $pk->x = $this->main->getFakeTile()->x;
         $pk->y = $this->main->getFakeTile()->y;
         $pk->z = $this->main->getFakeTile()->z;
         $pk->case1 = 1;
         $pk->case2 = 0;
         if (($level = $this->main->getFakeTile()->getLevel()) instanceof Level) {
             Server::broadcastPacket($level->getChunkPlayers($this->main->getFakeTile()->x >> 4, $this->main->getFakeTile()->z >> 4), $pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
         }
     }
     parent::onClose($who);
 }
开发者ID:barnseyminesuk,项目名称:Small-ZC-Plugins,代码行数:15,代码来源:InteractiveInventory.php

示例12: Light

 public function Light($x, $y, $z)
 {
     //雷
     $pk = new AddEntityPacket();
     $pk->type = 93;
     $pk->eid = Entity::$entityCount++;
     $pk->metadata = array();
     $pk->x = $x;
     $pk->y = $y;
     $pk->z = $z;
     $pk->speedX = 0;
     $pk->speedY = 0;
     $pk->speedZ = 0;
     Server::broadcastPacket(Server::getInstance()->getOnlinePlayers(), $pk);
 }
开发者ID:moinngmg,项目名称:MagicalAPI_Item,代码行数:15,代码来源:MagicalBow.php

示例13: onClose

 public function onClose(Player $who)
 {
     if (count($this->getViewers()) === 1) {
         $pk = new TileEventPacket();
         $pk->x = $this->getHolder()->getX();
         $pk->y = $this->getHolder()->getY();
         $pk->z = $this->getHolder()->getZ();
         $pk->case1 = 1;
         $pk->case2 = 0;
         if (($level = $this->getHolder()->getLevel()) instanceof Level) {
             Server::broadcastPacket($level->getUsingChunk($this->getHolder()->getX() >> 4, $this->getHolder()->getZ() >> 4), $pk);
         }
     }
     parent::onClose($who);
 }
开发者ID:TylerAndrew,项目名称:Steadfast2,代码行数:15,代码来源:ChestInventory.php

示例14: attack

 public function attack($damage, EntityDamageEvent $source)
 {
     parent::attack($damage, $source);
     if ($source->isCancelled()) {
         return;
     }
     if ($source instanceof EntityDamageByEntityEvent) {
         $this->swimSpeed = mt_rand(150, 350) / 2000;
         $e = $source->getDamager();
         $this->swimDirection = (new Vector3($this->x - $e->x, $this->y - $e->y, $this->z - $e->z))->normalize();
         $pk = new EntityEventPacket();
         $pk->eid = $this->getId();
         $pk->event = EntityEventPacket::SQUID_INK_CLOUD;
         Server::broadcastPacket($this->hasSpawned, $pk);
     }
 }
开发者ID:ianju,项目名称:PocketMine-MP,代码行数:16,代码来源:Squid.php

示例15: attack

 public function attack($damage, EntityDamageEvent $source)
 {
     parent::attack($damage, $source);
     if ($source->isCancelled()) {
         return;
     }
     if ($source instanceof EntityDamageByEntityEvent) {
         $this->swimSpeed = \mt_rand(150, 350) / 2000;
         $e = $source->getDamager();
         $this->swimDirection = (new Vector3($this->x - $e->x, $this->y - $e->y, $this->z - $e->z))->normalize();
         $pk = new EntityEventPacket();
         $pk->eid = $this->getId();
         $pk->event = 15;
         Server::broadcastPacket($this->hasSpawned, $pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
     }
 }
开发者ID:Edwardthedog2,项目名称:Steadfast2,代码行数:16,代码来源:Squid.php


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