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


PHP Server::broadcastPacket方法代码示例

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


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

示例1: attack

 public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC)
 {
     echo __METHOD__ . __LINE__ . "\n";
     if ($this->attackTime > 0 or $this->noDamageTicks > 0) {
         $lastCause = $this->getLastDamageCause();
         if ($lastCause instanceof EntityDamageEvent and $lastCause->getDamage() >= $damage) {
             if ($source instanceof EntityDamageEvent) {
                 $source->setCancelled();
                 $this->server->getPluginManager()->callEvent($source);
                 $damage = $source->getFinalDamage();
                 if ($source->isCancelled()) {
                     return;
                 }
             } else {
                 return;
             }
         } else {
             return;
         }
     } elseif ($source instanceof EntityDamageEvent) {
         $this->server->getPluginManager()->callEvent($source);
         $damage = $source->getFinalDamage();
         if ($source->isCancelled()) {
             return;
         }
     }
     $this->setLastDamageCause($source);
     if ($source instanceof EntityDamageByEntityEvent) {
         $e = $source->getDamager();
         $deltaX = $this->x - $e->x;
         $deltaZ = $this->z - $e->z;
         $yaw = atan2($deltaX, $deltaZ);
         $this->knockBack($e, $damage, sin($yaw), cos($yaw), $source->getKnockBack());
     }
     $this->setHealth($this->getHealth() - $damage);
     $pk = new EntityEventPacket();
     $pk->eid = $this->getId();
     $pk->event = $this->getHealth() <= 0 ? 3 : 2;
     //Ouch!
     Server::broadcastPacket($this->hasSpawned, $pk);
     $this->attackTime = 10;
     //0.5 seconds cooldown
 }
开发者ID:AvivShopen,项目名称:bad-plugins,代码行数:43,代码来源:Minecart.php

示例2: sendPosition

 public function sendPosition(Vector3 $pos, $yaw = null, $pitch = null, $mode = 0, array $targets = null)
 {
     $yaw = $yaw === null ? $this->yaw : $yaw;
     $pitch = $pitch === null ? $this->pitch : $pitch;
     $pk = new MovePlayerPacket();
     $pk->eid = $this->getId();
     $pk->x = $pos->x;
     $pk->y = $pos->y + $this->getEyeHeight();
     $pk->z = $pos->z;
     $pk->bodyYaw = $yaw;
     $pk->pitch = $pitch;
     $pk->yaw = $yaw;
     $pk->mode = $mode;
     if ($targets !== null) {
         Server::broadcastPacket($targets, $pk);
     } else {
         $pk->eid = 0;
         $this->dataPacket($pk);
     }
 }
开发者ID:MunkySkunk,项目名称:BukkitPE,代码行数:20,代码来源:Player.php

示例3: onClose

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


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