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


PHP Item::isHelmet方法代码示例

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


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

示例1: getPossibleEnchantments

 /**
  * @param Item $item
  * @param int  $modifiedLevel
  * @return Enchantment[]
  */
 public static function getPossibleEnchantments(Item $item, int $modifiedLevel)
 {
     $result = [];
     $enchantmentIds = [];
     if ($item->getId() == Item::BOOK) {
         $enchantmentIds = array_keys(self::$map);
     } elseif ($item->isArmor()) {
         $enchantmentIds[] = Enchantment::TYPE_ARMOR_PROTECTION;
         $enchantmentIds[] = Enchantment::TYPE_ARMOR_FIRE_PROTECTION;
         $enchantmentIds[] = Enchantment::TYPE_ARMOR_EXPLOSION_PROTECTION;
         $enchantmentIds[] = Enchantment::TYPE_ARMOR_PROJECTILE_PROTECTION;
         $enchantmentIds[] = Enchantment::TYPE_ARMOR_THORNS;
         if ($item->isBoots()) {
             $enchantmentIds[] = Enchantment::TYPE_ARMOR_FALL_PROTECTION;
         }
         if ($item->isHelmet()) {
             $enchantmentIds[] = Enchantment::TYPE_WATER_BREATHING;
             $enchantmentIds[] = Enchantment::TYPE_WATER_AFFINITY;
         }
     } elseif ($item->isSword()) {
         $enchantmentIds[] = Enchantment::TYPE_WEAPON_SHARPNESS;
         $enchantmentIds[] = Enchantment::TYPE_WEAPON_SMITE;
         $enchantmentIds[] = Enchantment::TYPE_WEAPON_ARTHROPODS;
         $enchantmentIds[] = Enchantment::TYPE_WEAPON_KNOCKBACK;
         $enchantmentIds[] = Enchantment::TYPE_WEAPON_FIRE_ASPECT;
         $enchantmentIds[] = Enchantment::TYPE_WEAPON_LOOTING;
     } elseif ($item->isTool()) {
         $enchantmentIds[] = Enchantment::TYPE_MINING_EFFICIENCY;
         $enchantmentIds[] = Enchantment::TYPE_MINING_SILK_TOUCH;
         $enchantmentIds[] = Enchantment::TYPE_MINING_FORTUNE;
     } elseif ($item->getId() == Item::BOW) {
         $enchantmentIds[] = Enchantment::TYPE_BOW_POWER;
         $enchantmentIds[] = Enchantment::TYPE_BOW_KNOCKBACK;
         $enchantmentIds[] = Enchantment::TYPE_BOW_FLAME;
         $enchantmentIds[] = Enchantment::TYPE_BOW_INFINITY;
     } elseif ($item->getId() == Item::FISHING_ROD) {
         $enchantmentIds[] = Enchantment::TYPE_FISHING_FORTUNE;
         $enchantmentIds[] = Enchantment::TYPE_FISHING_LURE;
     }
     if ($item->isTool() || $item->isArmor()) {
         $enchantmentIds[] = Enchantment::TYPE_MINING_DURABILITY;
     }
     foreach ($enchantmentIds as $enchantmentId) {
         $enchantment = Enchantment::getEnchantment($enchantmentId);
         $ranges = self::$map[$enchantmentId];
         $i = 0;
         /** @var Range $range */
         foreach ($ranges as $range) {
             $i++;
             if (self::isInRange($range[0], $range[1], $modifiedLevel)) {
                 $result[] = $enchantment->setLevel($i);
             }
         }
     }
     return $result;
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:61,代码来源:EnchantmentLevelTable.php


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