當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Item::isTool方法代碼示例

本文整理匯總了PHP中pocketmine\item\Item::isTool方法的典型用法代碼示例。如果您正苦於以下問題:PHP Item::isTool方法的具體用法?PHP Item::isTool怎麽用?PHP Item::isTool使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pocketmine\item\Item的用法示例。


在下文中一共展示了Item::isTool方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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

示例2: getCreativeItemIndex

 /**
  * @param Item $item
  * @return int
  */
 public static function getCreativeItemIndex(Item $item)
 {
     foreach (Item::$creative as $i => $d) {
         if ($item->equals($d, !$item->isTool())) {
             return $i;
         }
     }
     return -1;
 }
開發者ID:maa123,項目名稱:NIGHTMARE,代碼行數:13,代碼來源:Item.php

示例3: isCreativeItem

 public static function isCreativeItem(Item $item)
 {
     foreach (self::$creative as $i => $d) {
         if ($item->equals($d, !$item->isTool())) {
             return true;
         }
     }
     return false;
 }
開發者ID:Cecil107,項目名稱:PocketMine-0.13.0,代碼行數:9,代碼來源:Item.php

示例4: getEnchantAbility

 public static function getEnchantAbility(Item $item)
 {
     switch ($item->getId()) {
         case Item::BOOK:
         case Item::BOW:
         case Item::FISHING_ROD:
             return 4;
     }
     if ($item->isArmor()) {
         if ($item instanceof ChainBoots or $item instanceof ChainChestplate or $item instanceof ChainHelmet or $item instanceof ChainLeggings) {
             return 12;
         }
         if ($item instanceof IronBoots or $item instanceof IronChestplate or $item instanceof IronHelmet or $item instanceof IronLeggings) {
             return 9;
         }
         if ($item instanceof DiamondBoots or $item instanceof DiamondChestplate or $item instanceof DiamondHelmet or $item instanceof DiamondLeggings) {
             return 10;
         }
         if ($item instanceof LeatherBoots or $item instanceof LeatherTunic or $item instanceof LeatherCap or $item instanceof LeatherPants) {
             return 15;
         }
         if ($item instanceof GoldBoots or $item instanceof GoldChestplate or $item instanceof GoldHelmet or $item instanceof GoldLeggings) {
             return 25;
         }
     }
     if ($item->isTool()) {
         if ($item instanceof WoodenAxe or $item instanceof WoodenHoe or $item instanceof WoodenPickaxe or $item instanceof WoodenShovel or $item instanceof WoodenSword) {
             return 15;
         }
         if ($item instanceof StoneAxe or $item instanceof StoneHoe or $item instanceof StonePickaxe or $item instanceof StoneShovel or $item instanceof StoneSword) {
             return 5;
         }
         if ($item instanceof DiamondAxe or $item instanceof DiamondHoe or $item instanceof DiamondPickaxe or $item instanceof DiamondShovel or $item instanceof DiamondSword) {
             return 10;
         }
         if ($item instanceof IronAxe or $item instanceof IronHoe or $item instanceof IronPickaxe or $item instanceof IronShovel or $item instanceof IronSword) {
             return 14;
         }
         if ($item instanceof GoldAxe or $item instanceof GoldHoe or $item instanceof GoldPickaxe or $item instanceof GoldShovel or $item instanceof GoldSword) {
             return 22;
         }
     }
     return 0;
 }
開發者ID:ClearSkyTeam,項目名稱:ClearSky,代碼行數:44,代碼來源:Enchantment.php

示例5: getCreativeItemIndex

 public function getCreativeItemIndex(Item $item) : int
 {
     foreach ($this->personalCreativeItems as $i => $d) {
         if ($item->equals($d, !$item->isTool())) {
             return $i;
         }
     }
     return -1;
 }
開發者ID:iTXTech,項目名稱:Genisys,代碼行數:9,代碼來源:Player.php


注:本文中的pocketmine\item\Item::isTool方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。