Package net.minecraft.enchantment

Examples of net.minecraft.enchantment.Enchantment


      msg = msg.substring(0, msg.length() - 2);
      OutputHandler.chatNotification(sender, msg);
      return;
    }

    Enchantment ench = null;

    for (Enchantment enchL : Enchantment.enchantmentsList)
    {
      if (enchL != null)
      {
        if (StatCollector.translateToLocal(enchL.getName()).replaceAll(" ", "").equalsIgnoreCase(args[0]))
        {
          Map map = EnchantmentHelper.getEnchantments(var6);
          if (map.containsKey(enchL.effectId))
          {
            map.remove(enchL.effectId);
            EnchantmentHelper.setEnchantments(map, var6);
          }
          ench = enchL;
          break;
        }
      }
    }
    if (ench == null)
    {
      int var4 = parseIntBounded(sender, args[0], 0, Enchantment.enchantmentsList.length - 1);
      ench = Enchantment.enchantmentsList[var4];
    }
    if (ench == null)
    {
      OutputHandler.chatError(sender, String.format("'%s' is not a recognized enchantment.", args[0]));
      return;
    }

    int lvl = ench.getMaxLevel();
    if (args.length >= 2)
    {
      lvl = parseIntWithMin(sender, args[1], ench.getMinLevel());
    }

    var6.addEnchantment(ench, lvl);
  }
View Full Code Here


    return enchantments.get(name);
  }
 
  /** Helper method to get the level of that enchantment on the item. */
  public static int getLevel(ItemStack stack, String name) {
    Enchantment enchantment = get(name);
    if (enchantment == null) return 0;
    return EnchantmentHelper.getEnchantmentLevel(enchantment.effectId, stack);
  }
View Full Code Here

            int i1;
            int j1;
            int k1;
            int l1;
            Iterator iterator;
            Enchantment enchantment;

            if (inputB != null) {
                if (!ForgeHooks.onAnvilChange(this, inputA, inputB, outputSlot, repairedItemName, baseCost)) return;
                isBook = inputB.getItem() == Items.enchanted_book && Items.enchanted_book.func_92110_g(inputB).tagCount() > 0;

                if (inputACopy.isItemStackDamageable() && inputACopy.getItem().getIsRepairable(inputA, inputB)) {
                    l = Math.min(inputACopy.getItemDamageForDisplay(), inputACopy.getMaxDamage() / 4);

                    if (l <= 0) {
                        this.outputSlot.setInventorySlotContents(0, (ItemStack) null);
                        this.maximumCost = 0;
                        return;
                    }

                    for (i1 = 0; l > 0 && i1 < inputB.stackSize; ++i1) {
                        j1 = inputACopy.getItemDamageForDisplay() - l;
                        inputACopy.setItemDamage(j1);
                        i += Math.max(1, l / 100) + enchantments.size();
                        l = Math.min(inputACopy.getItemDamageForDisplay(), inputACopy.getMaxDamage() / 4);
                    }

                    this.stackSizeToBeUsedInRepair = i1;
                } else {
                    if (!isBook && (inputACopy.getItem() != inputB.getItem() || !inputACopy.isItemStackDamageable())) {
                        this.outputSlot.setInventorySlotContents(0, (ItemStack) null);
                        this.maximumCost = 0;
                        return;
                    }

                    if (inputACopy.isItemStackDamageable() && !isBook) {
                        l = inputA.getMaxDamage() - inputA.getItemDamageForDisplay();
                        i1 = inputB.getMaxDamage() - inputB.getItemDamageForDisplay();
                        j1 = i1 + inputACopy.getMaxDamage() * 12 / 100;
                        int i2 = l + j1;
                        k1 = inputACopy.getMaxDamage() - i2;

                        if (k1 < 0)
                            k1 = 0;

                        if (k1 < inputACopy.getItemDamage()) {
                            inputACopy.setItemDamage(k1);
                            i += Math.max(1, j1 / 100);
                        }
                    }

                    Map map1 = EnchantmentHelper.getEnchantments(inputB);
                    iterator = map1.keySet().iterator();

                    while (iterator.hasNext()) {
                        j1 = ((Integer) iterator.next()).intValue();
                        enchantment = Enchantment.enchantmentsList[j1];
                        k1 = enchantments.containsKey(Integer.valueOf(j1)) ? ((Integer) enchantments.get(Integer.valueOf(j1))).intValue() : 0;
                        l1 = ((Integer) map1.get(Integer.valueOf(j1))).intValue();
                        int j2;

                        if (k1 == l1) {
                            ++l1;
                            j2 = l1;
                        } else
                            j2 = Math.max(l1, k1);

                        l1 = j2;
                        int k2 = l1 - k1;
                        boolean isEnchantmentValid = enchantment.canApply(inputA);

                        if (player.capabilities.isCreativeMode || inputA.getItem() == Items.enchanted_book)
                            isEnchantmentValid = true;

                        Iterator iterator1 = enchantments.keySet().iterator();

                        while (iterator1.hasNext()) {
                            int l2 = ((Integer) iterator1.next()).intValue();

                            if (l2 != j1 && !enchantment.canApplyTogether(Enchantment.enchantmentsList[l2])) {
                                isEnchantmentValid = false;
                                i += k2;
                            }
                        }

                        if (isEnchantmentValid) {
                            if (l1 > enchantment.getMaxLevel())
                                l1 = enchantment.getMaxLevel();

                            enchantments.put(Integer.valueOf(j1), Integer.valueOf(l1));
                            int i3 = 0;

                            switch (enchantment.getWeight()) {
                                case 1:
                                    i3 = 8;
                                    break;
                                case 2:
                                    i3 = 4;
                                case 3:
                                case 4:
                                case 6:
                                case 7:
                                case 8:
                                case 9:
                                default:
                                    break;
                                case 5:
                                    i3 = 2;
                                    break;
                                case 10:
                                    i3 = 1;
                            }

                            if (isBook)
                                i3 = Math.max(1, i3 / 2);

                            i += i3 * k2;
                        }
                    }
                }
            }

            if (StringUtils.isBlank(this.repairedItemName)) {
                if (inputA.hasDisplayName()) {
                    j = inputA.isItemStackDamageable() ? 7 : inputA.stackSize * 5;
                    i += j;
                    inputACopy.func_135074_t();
                }
            } else if (!this.repairedItemName.equals(inputA.getDisplayName())) {
                j = inputA.isItemStackDamageable() ? 7 : inputA.stackSize * 5;
                i += j;

                if (inputA.hasDisplayName())
                    baseCost += j / 2;

                inputACopy.setStackDisplayName(this.repairedItemName);
            }

            l = 0;

            for (iterator = enchantments.keySet().iterator(); iterator.hasNext(); baseCost += l + k1 * l1) {
                j1 = ((Integer) iterator.next()).intValue();
                enchantment = Enchantment.enchantmentsList[j1];
                k1 = ((Integer) enchantments.get(Integer.valueOf(j1))).intValue();
                l1 = 0;
                ++l;

                switch (enchantment.getWeight()) {
                    case 1:
                        l1 = 8;
                        break;
                    case 2:
                        l1 = 4;
View Full Code Here

        Enchantment[] aenchantment = Enchantment.enchantmentsList;
        int j = aenchantment.length;

        for(int i = 0; i < j; ++i) {
            Enchantment enchantment = aenchantment[i];

            if(enchantment != null && enchantment.type != null) {
                Items.enchanted_book.func_92113_a(enchantment, containerSearcher.itemList);
            }
        }
View Full Code Here

    Map map1 = EnchantmentHelper.getEnchantments(central);
    Iterator iterator = map1.keySet().iterator();
        while (iterator.hasNext())
        {
          int j1 = ((Integer)iterator.next()).intValue();
            Enchantment ench = Enchantment.enchantmentsList[j1];
            if (j1 == enchantment.effectId &&
                EnchantmentHelper.getEnchantmentLevel(j1, central)>=ench.getMaxLevel())
              return false;
            if (enchantment.effectId != ench.effectId &&
              (!enchantment.canApplyTogether(ench) ||
              !ench.canApplyTogether(enchantment))) {
              return false;
            }
        }
   
    ItemStack i2 = null;
View Full Code Here

                //    Enchantment toolEnchant = Enchantment.enchantmentsList[((Integer)toolEnchantIterator.next()).intValue()];
                for(ItemStack enchantedBook : enchantedBooks) {
                    Map bookMap = EnchantmentHelper.getEnchantments(enchantedBook);
                    Iterator bookEnchantIterator = bookMap.keySet().iterator();
                    while(bookEnchantIterator.hasNext()) {
                        Enchantment bookEnchant = Enchantment.enchantmentsList[((Integer)bookEnchantIterator.next()).intValue()];
                        if(bookEnchant.canApply(inputStack)) {
                            return new ItemStack[]{inputStack, enchantedBook};
                        }
                    }
                }
                //  }
View Full Code Here

TOP

Related Classes of net.minecraft.enchantment.Enchantment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.