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


PHP entity\EntityDamageByEntityEvent类代码示例

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


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

示例1: handleDataPacket


//.........这里部分代码省略.........
             }
             $this->craftingType = 0;
             $target = $this->level->getEntity($packet->target);
             $cancelled = false;
             if ($target instanceof Player and $this->server->getConfigBoolean("pvp", true) === false) {
                 $cancelled = true;
             }
             if ($target instanceof Entity and $this->getGamemode() !== Player::VIEW and $this->dead !== true and $target->dead !== true) {
                 if ($target instanceof DroppedItem or $target instanceof Arrow) {
                     $this->kick("Attempting to attack an invalid entity");
                     $this->server->getLogger()->warning("Player " . $this->getName() . " tried to attack an invalid entity");
                     return;
                 }
                 $item = $this->inventory->getItemInHand();
                 $damageTable = [Item::WOODEN_SWORD => 4, Item::GOLD_SWORD => 4, Item::STONE_SWORD => 5, Item::IRON_SWORD => 6, Item::DIAMOND_SWORD => 7, Item::WOODEN_AXE => 3, Item::GOLD_AXE => 3, Item::STONE_AXE => 3, Item::IRON_AXE => 5, Item::DIAMOND_AXE => 6, Item::WOODEN_PICKAXE => 2, Item::GOLD_PICKAXE => 2, Item::STONE_PICKAXE => 3, Item::IRON_PICKAXE => 4, Item::DIAMOND_PICKAXE => 5, Item::WOODEN_SHOVEL => 1, Item::GOLD_SHOVEL => 1, Item::STONE_SHOVEL => 2, Item::IRON_SHOVEL => 3, Item::DIAMOND_SHOVEL => 4];
                 $damage = [EntityDamageEvent::MODIFIER_BASE => isset($damageTable[$item->getId()]) ? $damageTable[$item->getId()] : 1];
                 if ($this->distance($target) > 8) {
                     $cancelled = true;
                 } elseif ($target instanceof Player) {
                     if (($target->getGamemode() & 0x1) > 0) {
                         break;
                     } elseif ($this->server->getConfigBoolean("pvp") !== true or $this->server->getDifficulty() === 0) {
                         $cancelled = true;
                     }
                     $armorValues = [Item::LEATHER_CAP => 1, Item::LEATHER_TUNIC => 3, Item::LEATHER_PANTS => 2, Item::LEATHER_BOOTS => 1, Item::CHAIN_HELMET => 1, Item::CHAIN_CHESTPLATE => 5, Item::CHAIN_LEGGINGS => 4, Item::CHAIN_BOOTS => 1, Item::GOLD_HELMET => 1, Item::GOLD_CHESTPLATE => 5, Item::GOLD_LEGGINGS => 3, Item::GOLD_BOOTS => 1, Item::IRON_HELMET => 2, Item::IRON_CHESTPLATE => 6, Item::IRON_LEGGINGS => 5, Item::IRON_BOOTS => 2, Item::DIAMOND_HELMET => 3, Item::DIAMOND_CHESTPLATE => 8, Item::DIAMOND_LEGGINGS => 6, Item::DIAMOND_BOOTS => 3];
                     $points = 0;
                     foreach ($target->getInventory()->getArmorContents() as $index => $i) {
                         if (isset($armorValues[$i->getId()])) {
                             $points += $armorValues[$i->getId()];
                         }
                     }
                     $damage[EntityDamageEvent::MODIFIER_ARMOR] = -floor($damage[EntityDamageEvent::MODIFIER_BASE] * $points * 0.04);
                 }
                 $ev = new EntityDamageByEntityEvent($this, $target, EntityDamageEvent::CAUSE_ENTITY_ATTACK, $damage);
                 if ($cancelled) {
                     $ev->setCancelled();
                 }
                 $target->attack($ev->getFinalDamage(), $ev);
                 if ($ev->isCancelled()) {
                     if ($item->isTool() and $this->isSurvival()) {
                         $this->inventory->sendContents($this);
                     }
                     break;
                 }
                 if ($item->isTool() and $this->isSurvival()) {
                     if ($item->useOn($target) and $item->getDamage() >= $item->getMaxDurability()) {
                         $this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1), $this);
                     } else {
                         $this->inventory->setItemInHand($item, $this);
                     }
                 }
             }
             break;
         case ProtocolInfo::ANIMATE_PACKET:
             if ($this->spawned === false or $this->dead === true) {
                 break;
             }
             $this->server->getPluginManager()->callEvent($ev = new PlayerAnimationEvent($this, $packet->action));
             if ($ev->isCancelled()) {
                 break;
             }
             $pk = new AnimatePacket();
             $pk->eid = $this->getId();
             $pk->action = $ev->getAnimationType();
             Server::broadcastPacket($this->getViewers(), $pk);
             break;
开发者ID:WonderlandPE,项目名称:Steadfast2,代码行数:67,代码来源:Player.php

示例2: onFight

 /**
  * @param EntityDamageByEntityEvent $event
  * @priority HIGH
  * @ignoreCancelled true
  */
 public function onFight(EntityDamageByEntityEvent $event)
 {
     if (!$this->isFactionWorld($event->getEntity()->getLevel()->getName())) {
         return;
     }
     $victim = $event->getEntity();
     $attacker = $event->getDamager();
     if (!$attacker instanceof Player or !$victim instanceof Player) {
         return;
     }
     /** @noinspection PhpUnusedLocalVariableInspection */
     $at = $this->getFList()->getFaction(Chunk::fromObject($victim));
     $attackf = $this->getFList()->getFaction($attacker);
     $victimf = $this->getFList()->getFaction($victim);
     /** @noinspection PhpUnusedLocalVariableInspection */
     $state = $this->getFList()->getFactionsState($attackf, $victimf);
     // TODO
 }
开发者ID:MCPEGamerJPatGitHub,项目名称:PocketFactions,代码行数:23,代码来源:Main.php

示例3: handleDataPacket


//.........这里部分代码省略.........
             }
             $this->craftingType = 0;
             $target = $this->level->getEntity($packet->target);
             $cancelled = false;
             if ($target instanceof Player and $this->server->getConfigBoolean("pvp", true) === false) {
                 $cancelled = true;
             }
             if ($target instanceof Entity and $this->getGamemode() !== Player::VIEW and $this->dead !== true and $target->dead !== true) {
                 if ($target instanceof DroppedItem or $target instanceof Arrow) {
                     $this->kick("Attempting to attack an invalid entity");
                     $this->server->getLogger()->warning("Player " . $this->getName() . " tried to attack an invalid entity");
                     return;
                 }
                 $item = $this->inventory->getItemInHand();
                 $damageTable = [Item::WOODEN_SWORD => 4, Item::GOLD_SWORD => 4, Item::STONE_SWORD => 5, Item::IRON_SWORD => 6, Item::DIAMOND_SWORD => 7, Item::WOODEN_AXE => 3, Item::GOLD_AXE => 3, Item::STONE_AXE => 3, Item::IRON_AXE => 5, Item::DIAMOND_AXE => 6, Item::WOODEN_PICKAXE => 2, Item::GOLD_PICKAXE => 2, Item::STONE_PICKAXE => 3, Item::IRON_PICKAXE => 4, Item::DIAMOND_PICKAXE => 5, Item::WOODEN_SHOVEL => 1, Item::GOLD_SHOVEL => 1, Item::STONE_SHOVEL => 2, Item::IRON_SHOVEL => 3, Item::DIAMOND_SHOVEL => 4];
                 $damage = [EntityDamageEvent::MODIFIER_BASE => isset($damageTable[$item->getId()]) ? $damageTable[$item->getId()] : 1];
                 if ($this->distance($target) > 8) {
                     $cancelled = true;
                 } elseif ($target instanceof Player) {
                     if (($target->getGamemode() & 0x1) > 0) {
                         break;
                     } elseif ($this->server->getConfigBoolean("pvp") !== true or $this->server->getDifficulty() === 0) {
                         $cancelled = true;
                     }
                     $armorValues = [Item::LEATHER_CAP => 1, Item::LEATHER_TUNIC => 3, Item::LEATHER_PANTS => 2, Item::LEATHER_BOOTS => 1, Item::CHAIN_HELMET => 1, Item::CHAIN_CHESTPLATE => 5, Item::CHAIN_LEGGINGS => 4, Item::CHAIN_BOOTS => 1, Item::GOLD_HELMET => 1, Item::GOLD_CHESTPLATE => 5, Item::GOLD_LEGGINGS => 3, Item::GOLD_BOOTS => 1, Item::IRON_HELMET => 2, Item::IRON_CHESTPLATE => 6, Item::IRON_LEGGINGS => 5, Item::IRON_BOOTS => 2, Item::DIAMOND_HELMET => 3, Item::DIAMOND_CHESTPLATE => 8, Item::DIAMOND_LEGGINGS => 6, Item::DIAMOND_BOOTS => 3];
                     $points = 0;
                     foreach ($target->getInventory()->getArmorContents() as $index => $i) {
                         if (isset($armorValues[$i->getId()])) {
                             $points += $armorValues[$i->getId()];
                         }
                     }
                     $damage[EntityDamageEvent::MODIFIER_ARMOR] = -floor($damage[EntityDamageEvent::MODIFIER_BASE] * $points * 0.04);
                 }
                 $ev = new EntityDamageByEntityEvent($this, $target, EntityDamageEvent::CAUSE_ENTITY_ATTACK, $damage);
                 if ($cancelled) {
                     $ev->setCancelled();
                 }
                 $target->attack($ev->getFinalDamage(), $ev);
                 if ($ev->isCancelled()) {
                     if ($item->isTool() and $this->isSurvival()) {
                         $this->inventory->sendContents($this);
                     }
                     break;
                 }
                 if ($item->isTool() and $this->isSurvival()) {
                     if ($item->useOn($target) and $item->getDamage() >= $item->getMaxDurability()) {
                         $this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1), $this);
                     } else {
                         $this->inventory->setItemInHand($item, $this);
                     }
                 }
             }
             break;
         case ProtocolInfo::ANIMATE_PACKET:
             if ($this->spawned === false or $this->dead === true) {
                 break;
             }
             $this->server->getPluginManager()->callEvent($ev = new PlayerAnimationEvent($this, $packet->action));
             if ($ev->isCancelled()) {
                 break;
             }
             $pk = new AnimatePacket();
             $pk->eid = $this->getId();
             $pk->action = $ev->getAnimationType();
             Server::broadcastPacket($this->getViewers(), $pk);
             break;
开发者ID:rryy,项目名称:PocketMine-MP,代码行数:67,代码来源:Player.php

示例4: handleDataPacket


//.........这里部分代码省略.........
              */
             switch ($packet->action) {
                 case InteractPacket::ACTION_LEFT_CLICK:
                     //Attack
                     if ($target instanceof Player and $this->server->getConfigBoolean("pvp", true) === false) {
                         $cancelled = true;
                     }
                     if ($target instanceof Entity and $this->getGamemode() !== Player::VIEW and $this->isAlive() and $target->isAlive()) {
                         if ($target instanceof DroppedItem or $target instanceof Arrow) {
                             $this->kick("Attempting to attack an invalid entity");
                             $this->server->getLogger()->warning($this->getServer()->getLanguage()->translateString("pocketmine.player.invalidEntity", [$this->getName()]));
                             break;
                         }
                         $item = $this->inventory->getItemInHand();
                         $damageTable = [Item::WOODEN_SWORD => 4, Item::GOLD_SWORD => 4, Item::STONE_SWORD => 5, Item::IRON_SWORD => 6, Item::DIAMOND_SWORD => 7, Item::WOODEN_AXE => 3, Item::GOLD_AXE => 3, Item::STONE_AXE => 3, Item::IRON_AXE => 5, Item::DIAMOND_AXE => 6, Item::WOODEN_PICKAXE => 2, Item::GOLD_PICKAXE => 2, Item::STONE_PICKAXE => 3, Item::IRON_PICKAXE => 4, Item::DIAMOND_PICKAXE => 5, Item::WOODEN_SHOVEL => 1, Item::GOLD_SHOVEL => 1, Item::STONE_SHOVEL => 2, Item::IRON_SHOVEL => 3, Item::DIAMOND_SHOVEL => 4];
                         $damage = [EntityDamageEvent::MODIFIER_BASE => $damageTable[$item->getId()] ?? 1];
                         if (!$this->canInteract($target, 8)) {
                             $cancelled = true;
                         } elseif ($target instanceof Player) {
                             if (($target->getGamemode() & 0x1) > 0) {
                                 break;
                             } elseif ($this->server->getConfigBoolean("pvp") !== true or $this->server->getDifficulty() === 0) {
                                 $cancelled = true;
                             }
                             $armorValues = [Item::LEATHER_CAP => 1, Item::LEATHER_TUNIC => 3, Item::LEATHER_PANTS => 2, Item::LEATHER_BOOTS => 1, Item::CHAIN_HELMET => 1, Item::CHAIN_CHESTPLATE => 5, Item::CHAIN_LEGGINGS => 4, Item::CHAIN_BOOTS => 1, Item::GOLD_HELMET => 1, Item::GOLD_CHESTPLATE => 5, Item::GOLD_LEGGINGS => 3, Item::GOLD_BOOTS => 1, Item::IRON_HELMET => 2, Item::IRON_CHESTPLATE => 6, Item::IRON_LEGGINGS => 5, Item::IRON_BOOTS => 2, Item::DIAMOND_HELMET => 3, Item::DIAMOND_CHESTPLATE => 8, Item::DIAMOND_LEGGINGS => 6, Item::DIAMOND_BOOTS => 3];
                             $points = 0;
                             foreach ($target->getInventory()->getArmorContents() as $index => $i) {
                                 if (isset($armorValues[$i->getId()])) {
                                     $points += $armorValues[$i->getId()];
                                 }
                             }
                             $damage[EntityDamageEvent::MODIFIER_ARMOR] = -floor($damage[EntityDamageEvent::MODIFIER_BASE] * $points * 0.04);
                         }
                         $ev = new EntityDamageByEntityEvent($this, $target, EntityDamageEvent::CAUSE_ENTITY_ATTACK, $damage);
                         if ($cancelled) {
                             $ev->setCancelled();
                         }
                         $target->attack($ev->getFinalDamage(), $ev);
                         if ($ev->isCancelled()) {
                             if ($item->isTool() and $this->isSurvival()) {
                                 $this->inventory->sendContents($this);
                             }
                             break;
                         }
                         if ($this->isSurvival()) {
                             if ($item->isTool()) {
                                 if ($item->useOn($target) and $item->getDamage() >= $item->getMaxDurability()) {
                                     $this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1));
                                 } else {
                                     $this->inventory->setItemInHand($item);
                                 }
                             }
                             $this->exhaust(0.3, PlayerExhaustEvent::CAUSE_ATTACK);
                         }
                     }
                     break;
                 default:
                     break;
                     //TODO: handle other actions
             }
             break;
         case ProtocolInfo::ANIMATE_PACKET:
             if ($this->spawned === false or !$this->isAlive()) {
                 break;
             }
             $this->server->getPluginManager()->callEvent($ev = new PlayerAnimationEvent($this, $packet->action));
开发者ID:robske110,项目名称:ClearSky,代码行数:67,代码来源:Player.php

示例5: handleDataPacket


//.........这里部分代码省略.........
                 } elseif ($packet->action === InteractPacket::ACTION_LEFT_CLICK) {
                     if ($this->linkedEntity == $target) {
                         $target->setLinked(0, $this);
                     }
                     $target->close();
                 } elseif ($packet->action === InteractPacket::ACTION_LEAVE_VEHICLE) {
                     $this->setLinked(0, $target);
                 }
                 return;
             }
             if ($packet->action === InteractPacket::ACTION_RIGHT_CLICK) {
                 if ($target instanceof Animal and $this->getInventory()->getItemInHand()) {
                     //TODO: Feed
                 }
                 break;
             }
             if ($target instanceof Entity and $this->getGamemode() !== Player::VIEW and $this->isAlive() and $target->isAlive()) {
                 if ($target instanceof DroppedItem or $target instanceof Arrow) {
                     $this->kick("Attempting to attack an invalid entity");
                     $this->server->getLogger()->warning($this->getServer()->getLanguage()->translateString("pocketmine.player.invalidEntity", [$this->getName()]));
                     break;
                 }
                 $item = $this->inventory->getItemInHand();
                 $damage = [EntityDamageEvent::MODIFIER_BASE => $item->getModifyAttackDamage($target)];
                 if (!$this->canInteract($target, 8)) {
                     $cancelled = true;
                 } elseif ($target instanceof Player) {
                     if (($target->getGamemode() & 0x1) > 0) {
                         break;
                     } elseif ($this->server->getConfigBoolean("pvp") !== true or $this->server->getDifficulty() === 0) {
                         $cancelled = true;
                     }
                 }
                 $ev = new EntityDamageByEntityEvent($this, $target, EntityDamageEvent::CAUSE_ENTITY_ATTACK, $damage, 0.4 + $item->getEnchantmentLevel(Enchantment::TYPE_WEAPON_KNOCKBACK) * 0.15);
                 if ($cancelled) {
                     $ev->setCancelled();
                 }
                 if ($target->attack($ev->getFinalDamage(), $ev) === true) {
                     $fireAspectL = $item->getEnchantmentLevel(Enchantment::TYPE_WEAPON_FIRE_ASPECT);
                     if ($fireAspectL > 0) {
                         $fireEv = new EntityCombustByEntityEvent($this, $target, $fireAspectL * 4, $ev->getFireProtectL());
                         Server::getInstance()->getPluginManager()->callEvent($fireEv);
                         if (!$fireEv->isCancelled()) {
                             $target->setOnFire($fireEv->getDuration());
                         }
                     }
                     //Thorns
                     if ($this->isSurvival()) {
                         $ev->createThornsDamage();
                         if ($ev->getThornsDamage() > 0) {
                             $thornsEvent = new EntityDamageByEntityEvent($target, $this, EntityDamageEvent::CAUSE_ENTITY_ATTACK, $ev->getThornsDamage(), 0);
                             if (!$thornsEvent->isCancelled()) {
                                 if ($this->attack($thornsEvent->getFinalDamage(), $thornsEvent) === true) {
                                     $thornsEvent->useArmors();
                                     $ev->setThornsArmorUse();
                                 }
                             }
                         }
                     }
                     $ev->useArmors();
                 }
                 if ($ev->isCancelled()) {
                     if ($item->isTool() and $this->isSurvival()) {
                         $this->inventory->sendContents($this);
                     }
                     break;
开发者ID:iTXTech,项目名称:Genisys,代码行数:67,代码来源:Player.php

示例6: handleDataPacket


//.........这里部分代码省略.........
             }
             $this->craftingType = 0;
             $target = $this->level->getEntity($packet->target);
             $cancelled = false;
             if ($target instanceof Player and $this->server->getConfigBoolean("pvp", true) === false) {
                 $cancelled = true;
             }
             if ($target instanceof Entity and $this->getGamemode() !== Player::VIEW and $this->dead !== true and $target->dead !== true) {
                 if ($target instanceof DroppedItem or $target instanceof Arrow) {
                     $this->kick("Attempting to attack an invalid entity");
                     $this->server->getLogger()->warning($this->getServer()->getLanguage()->translateString("pocketmine.player.invalidEntity", [$this->getName()]));
                     return;
                 }
                 $item = $this->inventory->getItemInHand();
                 $damageTable = [Item::WOODEN_SWORD => 4, Item::GOLD_SWORD => 4, Item::STONE_SWORD => 5, Item::IRON_SWORD => 6, Item::DIAMOND_SWORD => 7, Item::WOODEN_AXE => 3, Item::GOLD_AXE => 3, Item::STONE_AXE => 3, Item::IRON_AXE => 5, Item::DIAMOND_AXE => 6, Item::WOODEN_PICKAXE => 2, Item::GOLD_PICKAXE => 2, Item::STONE_PICKAXE => 3, Item::IRON_PICKAXE => 4, Item::DIAMOND_PICKAXE => 5, Item::WOODEN_SHOVEL => 1, Item::GOLD_SHOVEL => 1, Item::STONE_SHOVEL => 2, Item::IRON_SHOVEL => 3, Item::DIAMOND_SHOVEL => 4];
                 $damage = [EntityDamageEvent::MODIFIER_BASE => isset($damageTable[$item->getId()]) ? $damageTable[$item->getId()] : 1];
                 if ($this->distance($target) > 8) {
                     $cancelled = true;
                 } elseif ($target instanceof Player) {
                     if (($target->getGamemode() & 0x1) > 0) {
                         break;
                     } elseif ($this->server->getConfigBoolean("pvp") !== true or $this->server->getDifficulty() === 0) {
                         $cancelled = true;
                     }
                     $armorValues = [Item::LEATHER_CAP => 1, Item::LEATHER_TUNIC => 3, Item::LEATHER_PANTS => 2, Item::LEATHER_BOOTS => 1, Item::CHAIN_HELMET => 1, Item::CHAIN_CHESTPLATE => 5, Item::CHAIN_LEGGINGS => 4, Item::CHAIN_BOOTS => 1, Item::GOLD_HELMET => 1, Item::GOLD_CHESTPLATE => 5, Item::GOLD_LEGGINGS => 3, Item::GOLD_BOOTS => 1, Item::IRON_HELMET => 2, Item::IRON_CHESTPLATE => 6, Item::IRON_LEGGINGS => 5, Item::IRON_BOOTS => 2, Item::DIAMOND_HELMET => 3, Item::DIAMOND_CHESTPLATE => 8, Item::DIAMOND_LEGGINGS => 6, Item::DIAMOND_BOOTS => 3];
                     $points = 0;
                     foreach ($target->getInventory()->getArmorContents() as $index => $i) {
                         if (isset($armorValues[$i->getId()])) {
                             $points += $armorValues[$i->getId()];
                         }
                     }
                     $damage[EntityDamageEvent::MODIFIER_ARMOR] = -floor($damage[EntityDamageEvent::MODIFIER_BASE] * $points * 0.04);
                 }
                 $ev = new EntityDamageByEntityEvent($this, $target, EntityDamageEvent::CAUSE_ENTITY_ATTACK, $damage);
                 if ($cancelled) {
                     $ev->setCancelled();
                 }
                 $target->attack($ev->getFinalDamage(), $ev);
                 if ($ev->isCancelled()) {
                     if ($item->isTool() and $this->isSurvival()) {
                         $this->inventory->sendContents($this);
                     }
                     break;
                 }
                 if ($item->isTool() and $this->isSurvival()) {
                     if ($item->useOn($target) and $item->getDamage() >= $item->getMaxDurability()) {
                         $this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1), $this);
                     } else {
                         $this->inventory->setItemInHand($item, $this);
                     }
                 }
             }
             break;
         case ProtocolInfo::ANIMATE_PACKET:
             if ($this->spawned === false or $this->dead === true) {
                 break;
             }
             $this->server->getPluginManager()->callEvent($ev = new PlayerAnimationEvent($this, $packet->action));
             if ($ev->isCancelled()) {
                 break;
             }
             $pk = new AnimatePacket();
             $pk->eid = $this->getId();
             $pk->action = $ev->getAnimationType();
             Server::broadcastPacket($this->getViewers(), $pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
             break;
开发者ID:TylerGames,项目名称:PocketMine-MP,代码行数:67,代码来源:Player.php

示例7: onEntityDamageByEntity

 /**
  * @param EntityDamageByEntityEvent $event
  *
  * @priority HIGH
  * @ignoreCancelled true
  */
 public function onEntityDamageByEntity(EntityDamageByEntityEvent $event)
 {
     $damager = $event->getDamager();
     $damaged = $event->getEntity();
     if ($damager instanceof Player && !$damager->isOp() && $damaged instanceof Player) {
         foreach ($this->plugin->getAllZones() as $zone) {
             if ($zone->isIn($damaged)) {
                 if ($zone->pvpAvailable) {
                     break;
                 }
                 $event->setCancelled(true);
                 $damager->sendMessage("[iZone] You are trying to attack in a private zone");
                 break;
             }
         }
     }
 }
开发者ID:Tee7even,项目名称:iZone,代码行数:23,代码来源:EventManager.php

示例8: onEntityDamageByEntity

 public function onEntityDamageByEntity(EntityDamageByEntityEvent $event)
 {
     $attacker = $event->getDamager();
     $victim = $event->getEntity();
     if ($attacker instanceof Player and $victim instanceof Player) {
         if ($attacker === $this->potato) {
             $this->potato->sendMessage(TextFormat::GOLD . "You gave up the potato to " . $victim->getName() . "!");
             $this->potato = $victim;
             $this->alertToPotato();
             $event->setCancelled(true);
         }
     }
 }
开发者ID:ChalkPE,项目名称:HotPotato,代码行数:13,代码来源:HotPotato.php

示例9: handleDataPacket


//.........这里部分代码省略.........
                 } elseif ($packet->action === InteractPacket::ACTION_LEFT_CLICK) {
                     if ($this->linkedEntity == $target) {
                         $target->setLinked(0, $this);
                     }
                     $target->close();
                 } elseif ($packet->action === InteractPacket::ACTION_LEAVE_VEHICLE) {
                     $this->setLinked(0, $target);
                 }
                 return;
             }
             if ($packet->action === InteractPacket::ACTION_RIGHT_CLICK) {
                 if ($target instanceof Animal and $this->getInventory()->getItemInHand()) {
                     //TODO: Feed
                 }
                 break;
             }
             if ($target instanceof Entity and $this->getGamemode() !== Player::VIEW and $this->isAlive() and $target->isAlive()) {
                 if ($target instanceof DroppedItem or $target instanceof Arrow) {
                     $this->kick("Attempting to attack an invalid entity");
                     $this->server->getLogger()->warning($this->getServer()->getLanguage()->translateString("pocketmine.player.invalidEntity", [$this->getName()]));
                     break;
                 }
                 $item = $this->inventory->getItemInHand();
                 $damage = [EntityDamageEvent::MODIFIER_BASE => $item->getModifyAttackDamage($target)];
                 if (!$this->canInteract($target, 8)) {
                     $cancelled = true;
                 } elseif ($target instanceof Player) {
                     if (($target->getGamemode() & 0x1) > 0) {
                         break;
                     } elseif ($this->server->getConfigBoolean("pvp") !== true or $this->server->getDifficulty() === 0) {
                         $cancelled = true;
                     }
                 }
                 $ev = new EntityDamageByEntityEvent($this, $target, EntityDamageEvent::CAUSE_ENTITY_ATTACK, $damage, 0.4 + $item->getEnchantmentLevel(Enchantment::TYPE_WEAPON_KNOCKBACK) * 0.15);
                 if ($cancelled) {
                     $ev->setCancelled();
                 }
                 if ($target->attack($ev->getFinalDamage(), $ev) === true) {
                     $fireAspectL = $item->getEnchantmentLevel(Enchantment::TYPE_WEAPON_FIRE_ASPECT);
                     if ($fireAspectL > 0) {
                         $fireEv = new EntityCombustByEntityEvent($this, $target, $fireAspectL * 4, $ev->getFireProtectL());
                         Server::getInstance()->getPluginManager()->callEvent($fireEv);
                         if (!$fireEv->isCancelled()) {
                             $target->setOnFire($fireEv->getDuration());
                         }
                     }
                     //Thorns
                     if ($this->isSurvival()) {
                         $ev->createThornsDamage();
                         if ($ev->getThornsDamage() > 0) {
                             $thornsEvent = new EntityDamageByEntityEvent($target, $this, EntityDamageEvent::CAUSE_ENTITY_ATTACK, $ev->getThornsDamage(), 0);
                             if (!$thornsEvent->isCancelled()) {
                                 if ($this->attack($thornsEvent->getFinalDamage(), $thornsEvent) === true) {
                                     $thornsEvent->useArmors();
                                     $ev->setThornsArmorUse();
                                 }
                             }
                         }
                     }
                     $ev->useArmors();
                 }
                 if ($ev->isCancelled()) {
                     if ($item->isTool() and $this->isSurvival()) {
                         $this->inventory->sendContents($this);
                     }
                     break;
开发者ID:yungtechboy1,项目名称:Genisys,代码行数:67,代码来源:Player.php

示例10: onPlayerDamagedByEntity

 public function onPlayerDamagedByEntity(EntityDamageByEntityEvent $event)
 {
     $attacker = $event->getDamager();
     $victim = $event->getEntity();
     if (!$victim instanceof Player) {
         return;
     }
     if (($vipVictim = $this->getVip($victim)) !== null and $vipVictim->refuseToPvp() or ($vipAttacker = $this->getVip($attacker)) !== null and $vipAttacker->refuseToPvp()) {
         $event->setDamage(0);
         $event->setCancelled(true);
         return;
     }
     if ($attacker instanceof Arrow and ($arrowIndex = array_search($attacker->getId(), $this->arrowQueue)) !== false) {
         $victim->setOnFire(10);
         unset($this->arrowQueue[$arrowIndex]);
     }
 }
开发者ID:nesgohood,项目名称:PMMP-Plugins,代码行数:17,代码来源:VIPPlus.php

示例11: onPlayerDamageByPlayerEvent

 public function onPlayerDamageByPlayerEvent(EntityDamageByEntityEvent $event)
 {
     $attacker = $event->getDamager();
     $victim = $event->getEntity();
     if (!($this->enabled and $attacker instanceof Player and $victim instanceof Player)) {
         return;
     }
     if (!($attacker->hasPermission("minigames.play") and $victim->hasPermission("minigames.play"))) {
         return;
     }
 }
开发者ID:nesgohood,项目名称:PMMP-Plugins,代码行数:11,代码来源:MiniGames.php

示例12: onHit

 public function onHit(\pocketmine\event\entity\EntityDamageByEntityEvent $ev)
 {
     if (!$ev->getEntity() instanceof Player or !$ev->getDamager() instanceof Player) {
         return;
     }
     if ($this->status !== 2) {
         $ev->setCancelled();
         $ev->getDamager()->sendMessage("[CrashBang] 정숙");
         return;
     }
     if ($this->skill[$ev->getDamager()->getName()] === Skills::INVINCIBLE and $this->ps[$ev->getDamager()->getName()] > microtime(true) or $this->skill[$ev->getEntity()->getName()] === Skills::INVINCIBLE and $this->ps[$ev->getEntity()->getName()] > microtime(true)) {
         $ev->setCancelled();
         $ev->getDamager()->sendMessage("[CrashBang] 당신 또는 대상이 무적 상태이므로 공격이 무시됩니다.");
         return;
     }
     if (in_array($this->skill[$ev->getDamager()->getName()], [Skills::BERSERKER, Skills::VAMPIRE, Skills::STEALTH, Skills::UPGRADE, Skills::POISONED_DAGGER])) {
         switch ($this->skill[$ev->getDamager()->getName()]) {
             case Skills::BERSERKER:
                 $ev->setDamage(floor((20 - $ev->getDamager()->getHealth()) / 4) * 2, 5);
                 break;
             case Skills::VAMPIRE:
                 $e = new EntityRegainHealthEvent($ev->getDamager(), 2, EntityRegainHealthEvent::CAUSE_MAGIC);
                 $ev->getDamager()->heal(2, $e);
                 break;
             case Skills::STEALTH:
                 $ev->getDamager()->removeEffect(Effect::INVISIBILITY);
                 break;
             case Skills::UPGRADE:
                 $ev->setDamage($this->ps[$ev->getDamager()->getName()], 5);
                 break;
             case Skills::POISONED_DAGGER:
                 $this->startCooldown($this->getDamager());
                 $ev->setDamage(5, 5);
                 break;
         }
     } else {
         if ($this->skill[$ev->getEntity()->getName()] === Skills::EYE_FOR_EYE and $this->ps[$ev->getEntity()->getName()]-- > 0) {
             if ($this->skill[$ev->getDamager()->getName()] === Skills::EYE_FOR_EYE) {
                 return;
             }
             $e = new EntityDamageByEntityEvent($ev->getEntity(), $ev->getDamager(), EntityDamageEvent::CAUSE_ENTITY_ATTACK, floor($ev->getFinalDamage() * 0.7));
             $ev->getDamager()->attack($e->getFinalDamage(), $e);
         } else {
             if ($ev->getDamager()->getInventory()->getItemInHand()->getID() === Item::BLAZE_ROD and in_array($this->skill[$ev->getDamager()->getName()], [Skills::ASSASSIN, Skills::TRACE])) {
                 $ev->setCancelled();
                 if ($this->cooldown[$ev->getDamager()->getName()] > 0) {
                     $ev->getDamager()->sendMessage("[CrashBang] 아직 스킬을 사용할 수 없습니다.");
                     $ev->setCancelled(false);
                     return;
                 }
                 switch ($this->skill[$ev->getDamager()->getName()]) {
                     case Skills::ASSASSIN:
                         $n = mt_rand(0, 99);
                         $ev->setCancelled(false);
                         if ($n < 30) {
                             $ev->setDamage(9999);
                         } else {
                             $e = new EntityDamageByEntityEvent($ev->getEntity(), $ev->getDamager(), EntityDamageEvent::CAUSE_ENTITY_ATTACK, 15);
                             $ev->getDamager()->attack($ev->getFinalDamage(), $e);
                             $ev->setDamage(15);
                         }
                         break;
                     case Skills::TRACE:
                         $this->getServer()->getScheduler()->scheduleDelayedTask(new TraceTask($this, $ev->getDamager(), $ev->getEntity()), 7 * 20);
                         $ev->getDamager()->sendMessage("[CrashBang] 7초 후 추적 대상" . $ev->getEntity()->getName() . "에게 이동합니다.");
                         break;
                 }
                 $this->startCooldown($ev->getDamager());
             }
         }
     }
 }
开发者ID:cr0sh,项目名称:CrashBang,代码行数:72,代码来源:CrashBang.php

示例13: __construct

 /**
  * @param Entity    $damager
  * @param Entity    $childEntity
  * @param Entity    $entity
  * @param int       $cause
  * @param int|int[] $damage
  */
 public function __construct(Entity $damager, Entity $childEntity, Entity $entity, $cause, $damage)
 {
     $this->childEntity = $childEntity;
     parent::__construct($damager, $entity, $cause, $damage);
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:12,代码来源:EntityDamageByChildEntityEvent.php

示例14: handleDataPacket


//.........这里部分代码省略.........
             }
             $this->craftingType = 0;
             $target = $this->level->getEntity($packet->target);
             $cancelled = false;
             if ($target instanceof Player and $this->server->getConfigBoolean("pvp", true) === false) {
                 $cancelled = true;
             }
             if ($target instanceof Entity and $this->getGamemode() !== Player::VIEW and $this->isAlive() and $target->isAlive()) {
                 if ($target instanceof DroppedItem or $target instanceof Arrow) {
                     $this->kick("Attempting to attack an invalid entity");
                     $this->server->getLogger()->warning($this->getServer()->getLanguage()->translateString("pocketmine.player.invalidEntity", [$this->getName()]));
                     break;
                 }
                 $item = $this->inventory->getItemInHand();
                 $damageTable = [Item::WOODEN_SWORD => 4, Item::GOLD_SWORD => 4, Item::STONE_SWORD => 5, Item::IRON_SWORD => 6, Item::DIAMOND_SWORD => 7, Item::WOODEN_AXE => 3, Item::GOLD_AXE => 3, Item::STONE_AXE => 3, Item::IRON_AXE => 5, Item::DIAMOND_AXE => 6, Item::WOODEN_PICKAXE => 2, Item::GOLD_PICKAXE => 2, Item::STONE_PICKAXE => 3, Item::IRON_PICKAXE => 4, Item::DIAMOND_PICKAXE => 5, Item::WOODEN_SHOVEL => 1, Item::GOLD_SHOVEL => 1, Item::STONE_SHOVEL => 2, Item::IRON_SHOVEL => 3, Item::DIAMOND_SHOVEL => 4];
                 $damage = [EntityDamageEvent::MODIFIER_BASE => isset($damageTable[$item->getId()]) ? $damageTable[$item->getId()] : 1];
                 if (!$this->canInteract($target, 8)) {
                     $cancelled = true;
                 } elseif ($target instanceof Player) {
                     if (($target->getGamemode() & 0x1) > 0) {
                         break;
                     } elseif ($this->server->getConfigBoolean("pvp") !== true or $this->server->getDifficulty() === 0) {
                         $cancelled = true;
                     }
                     $armorValues = [Item::LEATHER_CAP => 1, Item::LEATHER_TUNIC => 3, Item::LEATHER_PANTS => 2, Item::LEATHER_BOOTS => 1, Item::CHAIN_HELMET => 1, Item::CHAIN_CHESTPLATE => 5, Item::CHAIN_LEGGINGS => 4, Item::CHAIN_BOOTS => 1, Item::GOLD_HELMET => 1, Item::GOLD_CHESTPLATE => 5, Item::GOLD_LEGGINGS => 3, Item::GOLD_BOOTS => 1, Item::IRON_HELMET => 2, Item::IRON_CHESTPLATE => 6, Item::IRON_LEGGINGS => 5, Item::IRON_BOOTS => 2, Item::DIAMOND_HELMET => 3, Item::DIAMOND_CHESTPLATE => 8, Item::DIAMOND_LEGGINGS => 6, Item::DIAMOND_BOOTS => 3];
                     $points = 0;
                     foreach ($target->getInventory()->getArmorContents() as $index => $i) {
                         if (isset($armorValues[$i->getId()])) {
                             $points += $armorValues[$i->getId()];
                         }
                     }
                     $damage[EntityDamageEvent::MODIFIER_ARMOR] = -floor($damage[EntityDamageEvent::MODIFIER_BASE] * $points * 0.04);
                 }
                 $ev = new EntityDamageByEntityEvent($this, $target, EntityDamageEvent::CAUSE_ENTITY_ATTACK, $damage);
                 if ($cancelled) {
                     $ev->setCancelled();
                 }
                 $target->attack($ev->getFinalDamage(), $ev);
                 if ($ev->isCancelled()) {
                     if ($item->isTool() and $this->isSurvival()) {
                         $this->inventory->sendContents($this);
                     }
                     break;
                 }
                 if ($item->isTool() and $this->isSurvival()) {
                     if ($item->useOn($target) and $item->getDamage() >= $item->getMaxDurability()) {
                         $this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1));
                     } else {
                         $this->inventory->setItemInHand($item);
                     }
                 }
             }
             break;
         case ProtocolInfo::ANIMATE_PACKET:
             if ($this->spawned === false or !$this->isAlive()) {
                 break;
             }
             $this->server->getPluginManager()->callEvent($ev = new PlayerAnimationEvent($this, $packet->action));
             if ($ev->isCancelled()) {
                 break;
             }
             $pk = new AnimatePacket();
             $pk->eid = $this->getId();
             $pk->action = $ev->getAnimationType();
             Server::broadcastPacket($this->getViewers(), $pk);
             break;
开发者ID:NewDelion,项目名称:PocketMine-0.13.x,代码行数:67,代码来源:Player.php


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