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


PHP entity\ProjectileLaunchEvent类代码示例

本文整理汇总了PHP中pocketmine\event\entity\ProjectileLaunchEvent的典型用法代码示例。如果您正苦于以下问题:PHP ProjectileLaunchEvent类的具体用法?PHP ProjectileLaunchEvent怎么用?PHP ProjectileLaunchEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: attackEntity

 public function attackEntity(Entity $player)
 {
     if ($this->attackDelay > 25 && mt_rand(1, 12) < 3 && $this->distanceSquared($player) <= 40) {
         $this->attackDelay = 0;
         $f = 1.5;
         $yaw = $this->yaw + mt_rand(-180, 180) / 10;
         $pitch = $this->pitch + mt_rand(-90, 90) / 10;
         $nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $this->x), new Double("", $this->y + 1.62), new Double("", $this->z)]), "Motion" => new Enum("Motion", [new Double("", -sin($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * $f), new Double("", -sin($pitch / 180 * M_PI) * $f), new Double("", cos($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * $f)]), "Rotation" => new Enum("Rotation", [new Float("", $yaw), new Float("", $pitch)])]);
         /** @var Projectile $arrow */
         $arrow = Entity::createEntity("Arrow", $this->chunk, $nbt, $this);
         $ev = new EntityShootBowEvent($this, Item::get(Item::ARROW, 0, 1), $arrow, $f);
         $this->server->getPluginManager()->callEvent($ev);
         $projectile = $ev->getProjectile();
         if ($ev->isCancelled()) {
             $ev->getProjectile()->kill();
         } elseif ($projectile instanceof Projectile) {
             $this->server->getPluginManager()->callEvent($launch = new ProjectileLaunchEvent($projectile));
             if ($launch->isCancelled()) {
                 $projectile->kill();
             } else {
                 $projectile->spawnToAll();
                 $this->level->addSound(new LaunchSound($this), $this->getViewers());
             }
         }
     }
 }
开发者ID:rilex04,项目名称:EntityManager,代码行数:26,代码来源:Skeleton.php

示例2: attackEntity

 public function attackEntity(Entity $player)
 {
     if ($this->attackDelay > 30 && mt_rand(1, 32) < 4 && $this->distanceSquared($player) <= 200) {
         $this->attackDelay = 0;
         $f = 2;
         $yaw = $this->yaw + mt_rand(-220, 220) / 10;
         $pitch = $this->pitch + mt_rand(-120, 120) / 10;
         $nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x + -sin($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * 2), new DoubleTag("", $this->y + 2), new DoubleTag("", $this->z + cos($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * 2)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI)), new DoubleTag("", -sin($pitch / 180 * M_PI) * $f), new DoubleTag("", cos($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI))]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $yaw), new FloatTag("", $pitch)])]);
         $fireball = Entity::createEntity("FireBall", $this->chunk, $nbt, $this);
         if ($fireball instanceof FireBall) {
             $fireball->setExplode(true);
         }
         $fireball->setMotion($fireball->getMotion()->multiply($f));
         $ev = new EntityShootBowEvent($this, Item::get(Item::ARROW, 0, 1), $fireball, $f);
         $this->server->getPluginManager()->callEvent($ev);
         $projectile = $ev->getProjectile();
         if ($ev->isCancelled()) {
             $projectile->kill();
         } elseif ($projectile instanceof Projectile) {
             $this->server->getPluginManager()->callEvent($launch = new ProjectileLaunchEvent($projectile));
             if ($launch->isCancelled()) {
                 $projectile->kill();
             } else {
                 $projectile->spawnToAll();
                 $this->level->addSound(new LaunchSound($this), $this->getViewers());
             }
         }
     }
 }
开发者ID:steveritter,项目名称:EntityManager,代码行数:29,代码来源:Ghast.php

示例3: onProjectileLaunch

 public function onProjectileLaunch(ProjectileLaunchEvent $event)
 {
     try {
         $player = $event->getEntity()->shootingEntity;
         if ($player instanceof Player and $event->getEntity() instanceof Arrow) {
             if ($event->getEntity() instanceof Arrow) {
                 foreach ($this->plugin->gameLevelManager->levels as &$lv) {
                     if ($lv instanceof GameLevelModel) {
                         if (count($lv->joinedPlayers) === 0) {
                             continue;
                         }
                         if (isset($lv->currentMap)) {
                             if (isset($lv->currentMap->playerscores[$player->getName()])) {
                                 $lv->currentMap->shooters[$event->getEntity()->getId()] = $player->getName();
                                 $scores = $lv->currentMap->playerscores[$player->getName()];
                                 $scores["shots"] = $scores["shots"] + 1;
                                 $lv->currentMap->playerscores[$player->getName()] = $scores;
                                 break;
                             }
                         }
                     }
                 }
             }
         }
     } catch (\Exception $e) {
         $this->plugin->printError($e);
     }
 }
开发者ID:robozeri,项目名称:SG,代码行数:28,代码来源:ScoreListener.php

示例4: attackEntity

 public function attackEntity(Entity $player)
 {
     if ($this->attackDelay > 23 && mt_rand(1, 32) < 4 && $this->distanceSquared($player) <= 55) {
         $this->attackDelay = 0;
         $f = 1.2;
         $yaw = $this->yaw + mt_rand(-220, 220) / 10;
         $pitch = $this->pitch + mt_rand(-120, 120) / 10;
         $nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x + -sin($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * 0.5), new DoubleTag("", $this->y + 1), new DoubleTag("", $this->z + cos($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * 0.5)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI)), new DoubleTag("", -sin($pitch / 180 * M_PI)), new DoubleTag("", cos($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI))]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $yaw), new FloatTag("", $pitch)])]);
         /** @var Projectile $snowball */
         $snowball = Entity::createEntity("Snowball", $this->chunk, $nbt, $this);
         $snowball->setMotion($snowball->getMotion()->multiply($f));
         $property = (new \ReflectionClass($snowball))->getProperty("damage");
         $property->setAccessible(true);
         $property->setValue($snowball, 2);
         $ev = new EntityShootBowEvent($this, Item::get(Item::ARROW, 0, 1), $snowball, $f);
         $this->server->getPluginManager()->callEvent($ev);
         $projectile = $ev->getProjectile();
         if ($ev->isCancelled()) {
             $projectile->kill();
         } elseif ($projectile instanceof Projectile) {
             $this->server->getPluginManager()->callEvent($launch = new ProjectileLaunchEvent($projectile));
             if ($launch->isCancelled()) {
                 $projectile->kill();
             } else {
                 $projectile->spawnToAll();
                 $this->level->addSound(new LaunchSound($this), $this->getViewers());
             }
         }
     }
 }
开发者ID:steveritter,项目名称:EntityManager,代码行数:30,代码来源:SnowGolem.php

示例5: launch

 public function launch(Player $player)
 {
     $nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $player->x), new Double("", $player->y + $player->getEyeHeight()), new Double("", $player->z)]), "Motion" => new Enum("Motion", [new Double("", -sin($player->yaw / 180 * M_PI) * cos($player->pitch / 180 * M_PI)), new Double("", -sin($player->pitch / 180 * M_PI)), new Double("", cos($player->yaw / 180 * M_PI) * cos($player->pitch / 180 * M_PI))]), "Rotation" => new Enum("Rotation", [new Float("", $player->yaw), new Float("", $player->pitch)]), "Data" => new Byte("Data", $this->getDamage())]);
     $f = $this->f;
     $launched = Entity::createEntity($this->getEntityName(), $player->chunk, $nbt, $player);
     $launched->setMotion($launched->getMotion()->multiply($f));
     if ($launched instanceof Projectile) {
         $player->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($launched));
         if ($projectileEv->isCancelled()) {
             $launched->kill();
         } else {
             $launched->spawnToAll();
             $player->level->addSound(new LaunchSound($player), $player->getViewers());
         }
     } else {
         $launched->spawnToAll();
     }
     return true;
 }
开发者ID:SuperAdam47,项目名称:ClearSky,代码行数:19,代码来源:Launchable.php

示例6: handleDataPacket


//.........这里部分代码省略.........
                 if ($blockVector->distanceSquared($this) > 10000) {
                     break;
                 }
                 $target = $this->level->getBlock($blockVector);
                 $block = $target->getSide($packet->face);
                 $this->level->sendBlocks([$this], [$target, $block], UpdateBlockPacket::FLAG_ALL_PRIORITY);
                 break;
             } elseif ($packet->face === 0xff) {
                 $aimPos = (new Vector3($packet->x / 32768, $packet->y / 32768, $packet->z / 32768))->normalize();
                 if ($this->isCreative()) {
                     $item = $this->inventory->getItemInHand();
                 } elseif (!$this->inventory->getItemInHand()->deepEquals($packet->item)) {
                     $this->inventory->sendHeldItem($this);
                     break;
                 } else {
                     $item = $this->inventory->getItemInHand();
                 }
                 $ev = new PlayerInteractEvent($this, $item, $aimPos, $packet->face, PlayerInteractEvent::RIGHT_CLICK_AIR);
                 $this->server->getPluginManager()->callEvent($ev);
                 if ($ev->isCancelled()) {
                     $this->inventory->sendHeldItem($this);
                     break;
                 }
                 if ($item->getId() === Item::SNOWBALL) {
                     $nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $this->x), new Double("", $this->y + $this->getEyeHeight()), new Double("", $this->z)]), "Motion" => new Enum("Motion", [new Double("", $aimPos->x), new Double("", $aimPos->y), new Double("", $aimPos->z)]), "Rotation" => new Enum("Rotation", [new Float("", $this->yaw), new Float("", $this->pitch)])]);
                     $f = 1.5;
                     $snowball = Entity::createEntity("Snowball", $this->chunk, $nbt, $this);
                     $snowball->setMotion($snowball->getMotion()->multiply($f));
                     if ($this->isSurvival()) {
                         $item->setCount($item->getCount() - 1);
                         $this->inventory->setItemInHand($item->getCount() > 0 ? $item : Item::get(Item::AIR));
                     }
                     if ($snowball instanceof Projectile) {
                         $this->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($snowball));
                         if ($projectileEv->isCancelled()) {
                             $snowball->kill();
                         } else {
                             $snowball->spawnToAll();
                             $this->level->addSound(new LaunchSound($this), $this->getViewers());
                         }
                     } else {
                         $snowball->spawnToAll();
                     }
                 }
                 $this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION, true);
                 $this->startAction = $this->server->getTick();
             }
             break;
         case ProtocolInfo::PLAYER_ACTION_PACKET:
             if ($this->spawned === false or $this->blocked === true or $this->dead === true and $packet->action !== 7) {
                 break;
             }
             $this->craftingType = 0;
             $packet->eid = $this->id;
             $pos = new Vector3($packet->x, $packet->y, $packet->z);
             switch ($packet->action) {
                 case PlayerActionPacket::ACTION_START_BREAK:
                     if ($this->lastBreak !== PHP_INT_MAX or $pos->distanceSquared($this) > 10000) {
                         break;
                     }
                     $target = $this->level->getBlock($pos);
                     $ev = new PlayerInteractEvent($this, $this->inventory->getItemInHand(), $target, $packet->face, $target->getId() === 0 ? PlayerInteractEvent::LEFT_CLICK_AIR : PlayerInteractEvent::LEFT_CLICK_BLOCK);
                     $this->getServer()->getPluginManager()->callEvent($ev);
                     if ($ev->isCancelled()) {
                         $this->inventory->sendHeldItem($this);
                         break;
开发者ID:WonderlandPE,项目名称:Steadfast2,代码行数:67,代码来源:Player.php

示例7: handleDataPacket


//.........这里部分代码省略.........
                 $pk = new UpdateBlockPacket();
                 $pk->x = $block->x;
                 $pk->y = $block->y;
                 $pk->z = $block->z;
                 $pk->block = $block->getId();
                 $pk->meta = $block->getDamage();
                 $this->dataPacket($pk);
                 break;
             } elseif ($packet->face === 0xff) {
                 if ($this->isCreative()) {
                     $item = $this->inventory->getItemInHand();
                 } elseif ($this->inventory->getItemInHand()->getId() !== $packet->item or ($damage = $this->inventory->getItemInHand()->getDamage()) !== $packet->meta and $damage !== null) {
                     $this->inventory->sendHeldItem($this);
                     break;
                 } else {
                     $item = $this->inventory->getItemInHand();
                 }
                 $target = $this->level->getBlock($blockVector);
                 $ev = new PlayerInteractEvent($this, $item, $target, $packet->face);
                 $this->server->getPluginManager()->callEvent($ev);
                 if ($ev->isCancelled()) {
                     $this->inventory->sendHeldItem($this);
                     break;
                 }
                 if ($item->getId() === Item::SNOWBALL) {
                     $nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $this->x), new Double("", $this->y + $this->getEyeHeight()), new Double("", $this->z)]), "Motion" => new Enum("Motion", [new Double("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)), new Double("", -sin($this->pitch / 180 * M_PI)), new Double("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI))]), "Rotation" => new Enum("Rotation", [new Float("", $this->yaw), new Float("", $this->pitch)])]);
                     $f = 1.5;
                     $snowball = Entity::createEntity("Snowball", $this->chunk, $nbt, $this);
                     $snowball->setMotion($snowball->getMotion()->multiply($f));
                     if ($this->isSurvival()) {
                         $this->inventory->removeItem(Item::get(Item::SNOWBALL, 0, 1), $this);
                     }
                     if ($snowball instanceof Projectile) {
                         $this->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($snowball));
                         if ($projectileEv->isCancelled()) {
                             $snowball->kill();
                         } else {
                             $snowball->spawnToAll();
                         }
                     } else {
                         $snowball->spawnToAll();
                     }
                 }
                 $this->inAction = true;
                 $this->startAction = microtime(true);
                 $this->sendMetadata($this->getViewers());
             }
             break;
         case ProtocolInfo::PLAYER_ACTION_PACKET:
             if ($this->spawned === false or $this->blocked === true or $this->dead === true) {
                 break;
             }
             $this->craftingType = 0;
             $packet->eid = $this->id;
             switch ($packet->action) {
                 case 5:
                     //Shot arrow
                     if ($this->inventory->getItemInHand()->getId() === Item::BOW) {
                         $bow = $this->inventory->getItemInHand();
                         if ($this->isSurvival()) {
                             if (!$this->inventory->contains(Item::get(Item::ARROW, 0, 1))) {
                                 $this->inventory->sendContents($this);
                                 return;
                             }
                         }
                         $nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $this->x), new Double("", $this->y + $this->getEyeHeight()), new Double("", $this->z)]), "Motion" => new Enum("Motion", [new Double("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)), new Double("", -sin($this->pitch / 180 * M_PI)), new Double("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI))]), "Rotation" => new Enum("Rotation", [new Float("", $this->yaw), new Float("", $this->pitch)])]);
开发者ID:rryy,项目名称:PocketMine-MP,代码行数:67,代码来源:Player.php

示例8: checkArrow

 public function checkArrow(ProjectileLaunchEvent $event)
 {
     if ($event->getEntity() instanceof Arrow) {
         $this->getServer()->getScheduler()->scheduleDelayedTask(new CallbackTask([$this, "removeArrow"], [$event]), 20);
     }
 }
开发者ID:EmreTr1,项目名称:rtr,代码行数:6,代码来源:HungerGames.php

示例9: handleDataPacket


//.........这里部分代码省略.........
                 $ev = new PlayerInteractEvent($this, $item, $aimPos, $packet->face, PlayerInteractEvent::RIGHT_CLICK_AIR);
                 $this->server->getPluginManager()->callEvent($ev);
                 if ($ev->isCancelled()) {
                     $this->inventory->sendHeldItem($this);
                     break;
                 }
                 if ($item->getId() === Item::FISHING_ROD) {
                     if ($this->isFishing()) {
                         $this->server->getPluginManager()->callEvent($ev = new PlayerUseFishingRodEvent($this, PlayerUseFishingRodEvent::ACTION_STOP_FISHING));
                     } else {
                         $this->server->getPluginManager()->callEvent($ev = new PlayerUseFishingRodEvent($this, PlayerUseFishingRodEvent::ACTION_START_FISHING));
                     }
                     if (!$ev->isCancelled()) {
                         if ($this->isFishing()) {
                             $this->setFishingHook();
                         } else {
                             $nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x), new DoubleTag("", $this->y + $this->getEyeHeight()), new DoubleTag("", $this->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)), new DoubleTag("", -sin($this->pitch / 180 * M_PI)), new DoubleTag("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI))]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $this->yaw), new FloatTag("", $this->pitch)])]);
                             $f = 0.6;
                             $this->fishingHook = new FishingHook($this->chunk, $nbt, $this);
                             $this->fishingHook->setMotion($this->fishingHook->getMotion()->multiply($f));
                             $this->fishingHook->spawnToAll();
                         }
                     }
                 } elseif ($item->getId() === Item::SNOWBALL) {
                     $nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x), new DoubleTag("", $this->y + $this->getEyeHeight()), new DoubleTag("", $this->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)), new DoubleTag("", -sin($this->pitch / 180 * M_PI)), new DoubleTag("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI))]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $this->yaw), new FloatTag("", $this->pitch)])]);
                     $f = 1.5;
                     $snowball = Entity::createEntity("Snowball", $this->chunk, $nbt, $this);
                     $snowball->setMotion($snowball->getMotion()->multiply($f));
                     if ($this->isSurvival()) {
                         $item->setCount($item->getCount() - 1);
                         $this->inventory->setItemInHand($item->getCount() > 0 ? $item : Item::get(Item::AIR));
                     }
                     if ($snowball instanceof Projectile) {
                         $this->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($snowball));
                         if ($projectileEv->isCancelled()) {
                             $snowball->kill();
                         } else {
                             $snowball->spawnToAll();
                             $this->level->addSound(new LaunchSound($this), $this->getViewers());
                         }
                     } else {
                         $snowball->spawnToAll();
                     }
                 } elseif ($item->getId() === Item::EGG) {
                     $nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x), new DoubleTag("", $this->y + $this->getEyeHeight()), new DoubleTag("", $this->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)), new DoubleTag("", -sin($this->pitch / 180 * M_PI)), new DoubleTag("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI))]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $this->yaw), new FloatTag("", $this->pitch)])]);
                     $f = 1.5;
                     $egg = Entity::createEntity("Egg", $this->chunk, $nbt, $this);
                     $egg->setMotion($egg->getMotion()->multiply($f));
                     if ($this->isSurvival()) {
                         $item->setCount($item->getCount() - 1);
                         $this->inventory->setItemInHand($item->getCount() > 0 ? $item : Item::get(Item::AIR));
                     }
                     if ($egg instanceof Projectile) {
                         $this->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($egg));
                         if ($projectileEv->isCancelled()) {
                             $egg->kill();
                         } else {
                             $egg->spawnToAll();
                             $this->level->addSound(new LaunchSound($this), $this->getViewers());
                         }
                     } else {
                         $egg->spawnToAll();
                     }
                 } elseif ($item->getId() == Item::ENCHANTING_BOTTLE) {
                     $nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x), new DoubleTag("", $this->y + $this->getEyeHeight()), new DoubleTag("", $this->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)), new DoubleTag("", -sin($this->pitch / 180 * M_PI)), new DoubleTag("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI))]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $this->yaw), new FloatTag("", $this->pitch)])]);
                     $f = 1.1;
开发者ID:iTXTech,项目名称:Genisys,代码行数:67,代码来源:Player.php

示例10: handleDataPacket


//.........这里部分代码省略.........
                                 if ($item->getId() == Item::ARROW) {
                                     $arrow = $item;
                                 }
                             }
                             if ($arrow === false and $this->isCreative()) {
                                 $arrow = Item::get(Item::ARROW, 0, 1);
                             } elseif ($arrow === false) {
                                 break;
                             }
                             $nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x), new DoubleTag("", $this->y + $this->getEyeHeight()), new DoubleTag("", $this->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)), new DoubleTag("", -sin($this->pitch / 180 * M_PI)), new DoubleTag("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI))]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $this->yaw), new FloatTag("", $this->pitch)]), "Fire" => new ShortTag("Fire", $this->isOnFire() ? 45 * 60 : 0), "Potion" => new ShortTag("Potion", $arrow->getDamage())]);
                             $diff = $this->server->getTick() - $this->startAction;
                             $p = $diff / 20;
                             $f = min(($p ** 2 + $p * 2) / 3, 1) * 2;
                             $ev = new EntityShootBowEvent($this, $bow, Entity::createEntity("Arrow", $this->chunk, $nbt, $this, $f == 2 ? true : false), $f);
                             if ($f < 0.1 or $diff < 5) {
                                 $ev->setCancelled();
                             }
                             $this->server->getPluginManager()->callEvent($ev);
                             if ($ev->isCancelled()) {
                                 $ev->getProjectile()->kill();
                                 $this->inventory->sendContents($this);
                             } else {
                                 $ev->getProjectile()->setMotion($ev->getProjectile()->getMotion()->multiply($ev->getForce()));
                                 if ($this->isSurvival()) {
                                     $this->inventory->removeItem(Item::get(Item::ARROW, $arrow->getDamage(), 1));
                                     $bow->setDamage($bow->getDamage() + 1);
                                     if ($bow->getDamage() >= 385) {
                                         $this->inventory->setItemInHand(Item::get(Item::AIR, 0, 0));
                                     } else {
                                         $this->inventory->setItemInHand($bow);
                                     }
                                 }
                                 if ($ev->getProjectile() instanceof Projectile) {
                                     $this->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($ev->getProjectile()));
                                     if ($projectileEv->isCancelled()) {
                                         $ev->getProjectile()->kill();
                                     } else {
                                         $ev->getProjectile()->spawnToAll();
                                         $this->level->addSound(new LaunchSound($this), $this->getViewers());
                                     }
                                 } else {
                                     $ev->getProjectile()->spawnToAll();
                                 }
                             }
                         }
                     } elseif ($this->inventory->getItemInHand()->getId() === Item::BUCKET and $this->inventory->getItemInHand()->getDamage() === 1) {
                         //Milk!
                         $this->server->getPluginManager()->callEvent($ev = new PlayerItemConsumeEvent($this, $this->inventory->getItemInHand()));
                         if ($ev->isCancelled()) {
                             $this->inventory->sendContents($this);
                             break;
                         }
                         $pk = new EntityEventPacket();
                         $pk->eid = $this->getId();
                         $pk->event = EntityEventPacket::USE_ITEM;
                         $this->dataPacket($pk);
                         Server::broadcastPacket($this->getViewers(), $pk);
                         if ($this->isSurvival()) {
                             $slot = $this->inventory->getItemInHand();
                             --$slot->count;
                             $this->inventory->setItemInHand($slot);
                             $this->inventory->addItem(Item::get(Item::BUCKET, 0, 1));
                         }
                         $this->removeAllEffects();
                     } else {
                         $this->inventory->sendContents($this);
开发者ID:robske110,项目名称:ClearSky,代码行数:67,代码来源:Player.php

示例11: burstArrow

 public function burstArrow(Player $player)
 {
     if ($player->getInventory()->getItemInHand()->getId() === Item::BOW) {
         $bow = $player->getInventory()->getItemInHand();
         $nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $player->x), new Double("", $player->y + $player->getEyeHeight()), new Double("", $player->z)]), "Motion" => new Enum("Motion", [new Double("", -\sin($player->yaw / 180 * M_PI) * \cos($player->pitch / 180 * M_PI)), new Double("", -\sin($player->pitch / 180 * M_PI)), new Double("", \cos($player->yaw / 180 * M_PI) * \cos($player->pitch / 180 * M_PI))]), "Rotation" => new Enum("Rotation", [new Float("", $player->yaw), new Float("", $player->pitch)])]);
         $ev = new EntityShootBowEvent($player, $bow, Entity::createEntity("Arrow", $player->chunk, $nbt, $player), 1.5);
         $this->getServer()->getPluginManager()->callEvent($ev);
         if ($ev->isCancelled()) {
             $ev->getProjectile()->kill();
         } else {
             $ev->getProjectile()->setMotion($ev->getProjectile()->getMotion()->multiply($ev->getForce()));
             if ($ev->getProjectile() instanceof Projectile) {
                 $this->getServer()->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($ev->getProjectile()));
                 if ($projectileEv->isCancelled()) {
                     $ev->getProjectile()->kill();
                 } else {
                     $this->object_hash[spl_object_hash($ev->getProjectile())] = 1;
                     $ev->getProjectile()->spawnToAll();
                 }
             } else {
                 $this->object_hash[spl_object_hash($ev->getProjectile())] = 1;
                 $ev->getProjectile()->spawnToAll();
             }
         }
     }
 }
开发者ID:EmreTr1,项目名称:rtr,代码行数:26,代码来源:burstMode.php

示例12: handleDataPacket


//.........这里部分代码省略.........
                 if ($blockVector->distanceSquared($this) > 10000) {
                     break;
                 }
                 $target = $this->level->getBlock($blockVector);
                 $block = $target->getSide($packet->face);
                 $this->level->sendBlocks([$this], [$target, $block], UpdateBlockPacket::FLAG_ALL_PRIORITY);
                 break;
             } elseif ($packet->face === 0xff) {
                 $aimPos = (new Vector3($packet->x / 32768, $packet->y / 32768, $packet->z / 32768))->normalize();
                 if ($this->isCreative()) {
                     $item = $this->inventory->getItemInHand();
                 } elseif ($this->inventory->getItemInHand()->getId() !== $packet->item or ($damage = $this->inventory->getItemInHand()->getDamage()) !== $packet->meta and $damage !== null) {
                     $this->inventory->sendHeldItem($this);
                     break;
                 } else {
                     $item = $this->inventory->getItemInHand();
                 }
                 $ev = new PlayerInteractEvent($this, $item, $aimPos, $packet->face, PlayerInteractEvent::RIGHT_CLICK_AIR);
                 $this->server->getPluginManager()->callEvent($ev);
                 if ($ev->isCancelled()) {
                     $this->inventory->sendHeldItem($this);
                     break;
                 }
                 if ($item->getId() === Item::SNOWBALL) {
                     $nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $this->x), new Double("", $this->y + $this->getEyeHeight()), new Double("", $this->z)]), "Motion" => new Enum("Motion", [new Double("", $aimPos->x), new Double("", $aimPos->y), new Double("", $aimPos->z)]), "Rotation" => new Enum("Rotation", [new Float("", $this->yaw), new Float("", $this->pitch)])]);
                     $f = 1.5;
                     $snowball = Entity::createEntity("Snowball", $this->chunk, $nbt, $this);
                     $snowball->setMotion($snowball->getMotion()->multiply($f));
                     if ($this->isSurvival()) {
                         $item->setCount($item->getCount() - 1);
                         $this->inventory->setItemInHand($item->getCount() > 0 ? $item : Item::get(Item::AIR));
                     }
                     if ($snowball instanceof Projectile) {
                         $this->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($snowball));
                         if ($projectileEv->isCancelled()) {
                             $snowball->kill();
                         } else {
                             $snowball->spawnToAll();
                             $this->level->addSound(new LaunchSound($this), $this->getViewers());
                         }
                     } else {
                         $snowball->spawnToAll();
                     }
                 }
                 $this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION, true);
                 $this->startAction = $this->server->getTick();
             }
             break;
         case ProtocolInfo::PLAYER_ACTION_PACKET:
             if ($this->spawned === false or $this->blocked === true or $this->dead === true and $packet->action !== 7) {
                 break;
             }
             $this->craftingType = 0;
             $packet->eid = $this->id;
             $pos = new Vector3($packet->x, $packet->y, $packet->z);
             switch ($packet->action) {
                 case 0:
                     //Start break
                     if ($pos->distanceSquared($this) > 10000) {
                         break;
                     }
                     $target = $this->level->getBlock($pos);
                     $ev = new PlayerInteractEvent($this, $this->inventory->getItemInHand(), $target, $packet->face, $target->getId() === 0 ? PlayerInteractEvent::LEFT_CLICK_AIR : PlayerInteractEvent::LEFT_CLICK_BLOCK);
                     $this->getServer()->getPluginManager()->callEvent($ev);
                     if ($ev->isCancelled()) {
                         $this->inventory->sendHeldItem($this);
开发者ID:TylerGames,项目名称:PocketMine-MP,代码行数:67,代码来源:Player.php

示例13: handleDataPacket


//.........这里部分代码省略.........
                 $ev = new PlayerInteractEvent($this, $item, $aimPos, $packet->face, PlayerInteractEvent::RIGHT_CLICK_AIR);
                 $this->server->getPluginManager()->callEvent($ev);
                 if ($ev->isCancelled()) {
                     $this->inventory->sendHeldItem($this);
                     break;
                 }
                 if ($item->getId() === Item::FISHING_ROD) {
                     if ($this->isFishing()) {
                         $this->server->getPluginManager()->callEvent($ev = new PlayerUseFishingRodEvent($this, PlayerUseFishingRodEvent::ACTION_STOP_FISHING));
                     } else {
                         $this->server->getPluginManager()->callEvent($ev = new PlayerUseFishingRodEvent($this, PlayerUseFishingRodEvent::ACTION_START_FISHING));
                     }
                     if (!$ev->isCancelled()) {
                         if ($this->isFishing()) {
                             $this->setFishingHook();
                         } else {
                             $nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x), new DoubleTag("", $this->y + $this->getEyeHeight()), new DoubleTag("", $this->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)), new DoubleTag("", -sin($this->pitch / 180 * M_PI)), new DoubleTag("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI))]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $this->yaw), new FloatTag("", $this->pitch)])]);
                             $f = 0.6;
                             $this->fishingHook = new FishingHook($this->chunk, $nbt, $this);
                             $this->fishingHook->setMotion($this->fishingHook->getMotion()->multiply($f));
                             $this->fishingHook->spawnToAll();
                         }
                     }
                 } elseif ($item->getId() === Item::SNOWBALL) {
                     $nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x), new DoubleTag("", $this->y + $this->getEyeHeight()), new DoubleTag("", $this->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)), new DoubleTag("", -sin($this->pitch / 180 * M_PI)), new DoubleTag("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI))]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $this->yaw), new FloatTag("", $this->pitch)])]);
                     $f = 1.5;
                     $snowball = Entity::createEntity("Snowball", $this->chunk, $nbt, $this);
                     $snowball->setMotion($snowball->getMotion()->multiply($f));
                     if ($this->isSurvival()) {
                         $item->setCount($item->getCount() - 1);
                         $this->inventory->setItemInHand($item->getCount() > 0 ? $item : Item::get(Item::AIR));
                     }
                     if ($snowball instanceof Projectile) {
                         $this->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($snowball));
                         if ($projectileEv->isCancelled()) {
                             $snowball->kill();
                         } else {
                             $snowball->spawnToAll();
                             $this->level->addSound(new LaunchSound($this), $this->getViewers());
                         }
                     } else {
                         $snowball->spawnToAll();
                     }
                 } elseif ($item->getId() === Item::EGG) {
                     $nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x), new DoubleTag("", $this->y + $this->getEyeHeight()), new DoubleTag("", $this->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)), new DoubleTag("", -sin($this->pitch / 180 * M_PI)), new DoubleTag("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI))]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $this->yaw), new FloatTag("", $this->pitch)])]);
                     $f = 1.5;
                     $egg = Entity::createEntity("Egg", $this->chunk, $nbt, $this);
                     $egg->setMotion($egg->getMotion()->multiply($f));
                     if ($this->isSurvival()) {
                         $item->setCount($item->getCount() - 1);
                         $this->inventory->setItemInHand($item->getCount() > 0 ? $item : Item::get(Item::AIR));
                     }
                     if ($egg instanceof Projectile) {
                         $this->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($egg));
                         if ($projectileEv->isCancelled()) {
                             $egg->kill();
                         } else {
                             $egg->spawnToAll();
                             $this->level->addSound(new LaunchSound($this), $this->getViewers());
                         }
                     } else {
                         $egg->spawnToAll();
                     }
                 } elseif ($item->getId() == Item::ENCHANTING_BOTTLE) {
                     $nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x), new DoubleTag("", $this->y + $this->getEyeHeight()), new DoubleTag("", $this->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)), new DoubleTag("", -sin($this->pitch / 180 * M_PI)), new DoubleTag("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI))]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $this->yaw), new FloatTag("", $this->pitch)])]);
                     $f = 1.1;
开发者ID:yungtechboy1,项目名称:Genisys,代码行数:67,代码来源:Player.php

示例14: onLaunch

 public function onLaunch(ProjectileLaunchEvent $event)
 {
     $shooter = $event->getEntity()->shootingEntity;
     if ($shooter instanceof Player) {
         if ($this->checkSpawn($shooter, 5)) {
             $this->message($shooter, $this->get("cannot-spawn-pvp"));
             $event->setCancelled();
         }
     }
 }
开发者ID:nesgohood,项目名称:PMMP-Plugins,代码行数:10,代码来源:GoodSPAWN.php

示例15: checkArrow

 public function checkArrow(ProjectileLaunchEvent $event)
 {
     if ($event->getEntity() instanceof Arrow) {
         $this->getServer()->getScheduler()->scheduleDelayedTask(new removeArrowTask($event, $this->getServer()), 20);
     }
 }
开发者ID:nesgohood,项目名称:PMMP-Plugins,代码行数:6,代码来源:HungerGames.php


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