當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。