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


PHP Item::getEnchantments方法代碼示例

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


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

示例1: onEnchant

 public function onEnchant(Player $who, Item $before, Item $after)
 {
     $result = $before->getId() == Item::BOOK ? new EnchantedBook() : $before;
     if (!$before->hasEnchantments() and $after->hasEnchantments() and $after->getId() == $result->getId() and $this->levels != null and $this->entries != null) {
         $enchantments = $after->getEnchantments();
         for ($i = 0; $i < 3; $i++) {
             if ($enchantments == $this->entries[$i]->getEnchantments()) {
                 $lapis = $this->getItem(1);
                 $level = $who->getExpLevel();
                 $exp = $who->getExperience();
                 $cost = $this->entries[$i]->getCost();
                 if ($lapis->getId() == Item::DYE and $lapis->getDamage() == Dye::BLUE and $lapis->getCount() > $i and $level >= $cost) {
                     foreach ($enchantments as $enchantment) {
                         $result->addEnchantment($enchantment);
                     }
                     $this->setItem(0, $result);
                     $lapis->setCount($lapis->getCount() - $i - 1);
                     $this->setItem(1, $lapis);
                     $who->setExperienceAndLevel($exp, $level - $cost);
                     break;
                 }
             }
         }
     }
 }
開發者ID:xpyctum,項目名稱:Genisys,代碼行數:25,代碼來源:EnchantInventory.php


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