Package net.minecraft.enchantment

Examples of net.minecraft.enchantment.Enchantment


      if (index >= enchanter.enchantments.size() || index >= enchanter.levels.size())
        return;

      int level = enchanter.levels.get(index);

      Enchantment enchant = Enchantment.enchantmentsList[enchanter.enchantments.get(index)];

      switch (type) {
        case 0: {
          ThaumicTinkerer.netHandler.sendToServer(new PacketEnchanterAddEnchant(enchanter, enchant.effectId, -1));
          break;
View Full Code Here


    Map<Number, Number> enchants = EnchantmentHelper.getEnchantments(result);
    List<EnchanterRecipe> recipes = EnchanterRecipeManager.getInstance().getRecipes();

    for (Number id : enchants.keySet()) {
      if(id != null && id.intValue() >= 0 && id.intValue() < Enchantment.enchantmentsList.length) {
        Enchantment ench = Enchantment.enchantmentsList[id.intValue()];
        if(ench != null && ench.getName() != null) {

          for (EnchanterRecipe recipe : recipes) {
            if(recipe.isValid() && recipe.getEnchantment().getName().equals(ench.getName())) {
              EnchantmentData enchantment = new EnchantmentData(recipe.getEnchantment(), 1);
              ItemStack output = new ItemStack(Items.enchanted_book);
              Items.enchanted_book.addEnchantment(output, enchantment);
              EnchanterRecipeNEI rec = new EnchanterRecipeNEI(recipe, output, enchantment);
              arecipes.add(rec);
View Full Code Here

    int res = 0;
    Map map1 = EnchantmentHelper.getEnchantments(itemStack);
    Iterator iter = map1.keySet().iterator();
    while (iter.hasNext()) {
      int i1 = ((Integer) iter.next()).intValue();
      Enchantment enchantment = Enchantment.enchantmentsList[i1];

      int level = ((Integer) map1.get(Integer.valueOf(i1))).intValue();
      if(enchantment.canApply(itemStack)) {
        if(level > enchantment.getMaxLevel()) {
          level = enchantment.getMaxLevel();
        }
        int costPerLevel = 0;
        switch (enchantment.getWeight()) {
        case 1:
          costPerLevel = 8;
          break;
        case 2:
          costPerLevel = 4;
View Full Code Here

      return 0;
    }
    if(currentEnchantment == null) {
      return 0;
    }
    Enchantment enchantment = currentEnchantment.getEnchantment();
    int level = item.stackSize;
    return getEnchantmentCost(currentEnchantment, level);
  }
View Full Code Here

          @SuppressWarnings("unchecked")
          Map<Integer, Integer> addedEnchantments = EnchantmentHelper.getEnchantments(addedItem);
         
          for(Integer addedEnchId : addedEnchantments.keySet())
          {
            Enchantment enchantment = Enchantment.enchantmentsList[addedEnchId];
            int existingEnchLevel = existingEnchantments.containsKey(addedEnchId) ? existingEnchantments.get(addedEnchId) : 0;
            int addedEnchLevel = addedEnchantments.get(addedEnchId);
            int newEnchLevel;
           
            if(existingEnchLevel == addedEnchLevel)
            {
              ++addedEnchLevel;
              newEnchLevel = addedEnchLevel;
            }
            else
            {
              newEnchLevel = Math.max(addedEnchLevel, existingEnchLevel);
            }
           
            addedEnchLevel = newEnchLevel;
            int levelDifference = addedEnchLevel - existingEnchLevel;
            boolean canEnchantmentBeAdded = enchantment.canApply(outputItem);
           
            if(outputItem.itemID == ItemEnchantedBook.enchantedBook.itemID)
            {
              canEnchantmentBeAdded = true;
            }
           
            for(Integer existingEnchId : existingEnchantments.keySet())
            {
              if(existingEnchId != addedEnchId && !enchantment.canApplyTogether(Enchantment.enchantmentsList[existingEnchId]))
              {
                canEnchantmentBeAdded = false;
                totalEnchCost += levelDifference;
              }
            }
           
            if(canEnchantmentBeAdded)
            {
              if(newEnchLevel > enchantment.getMaxLevel())
              {
                newEnchLevel = enchantment.getMaxLevel();
              }
             
              existingEnchantments.put(Integer.valueOf(addedEnchId), Integer.valueOf(newEnchLevel));
              int enchCost = 0;
             
              switch(enchantment.getWeight())
              {
              case 1:
                enchCost = 8;
                break;
              case 2:
                enchCost = 4;
              case 3:
              case 4:
              case 6:
              case 7:
              case 8:
              case 9:
              default:
                break;
              case 5:
                enchCost = 2;
                break;
              case 10:
                enchCost = 1;
              }
             
              if(enchantingWithBook)
              {
                enchCost = Math.max(1, enchCost / 2);
              }
             
              totalEnchCost += enchCost * levelDifference;
            }
          }
        }
      }
     
      int enchCount = 0;
     
      for(Integer existingEnchId : existingEnchantments.keySet())
      {
        Enchantment enchantment = Enchantment.enchantmentsList[existingEnchId];
        int existingEnchLevel = existingEnchantments.get(existingEnchId);
        int enchCost = 0;
        ++enchCount;
       
        switch(enchantment.getWeight())
        {
        case 1:
          enchCost = 8;
          break;
        case 2:
View Full Code Here

    HashMap<Integer, EnchantmentData> enchantmentMap = null;
    boolean isBook = stack.itemID == Item.book.itemID;
   
    for(int var7 = 0; var7 < Enchantment.enchantmentsList.length; ++var7)
    {
      Enchantment enchantment = Enchantment.enchantmentsList[var7];
     
      if(enchantment != null && (isBook || enchantment.canApplyAtEnchantingTable(stack)))
      {
        for(int enchLevel = enchantment.getMinLevel(); enchLevel <= enchantment.getMaxLevel(); ++enchLevel)
        {
          if(targetEnchantability >= enchantment.getMinEnchantability(enchLevel) && targetEnchantability <= enchantment.getMaxEnchantability(enchLevel))
          {
            if(enchantmentMap == null)
            {
              enchantmentMap = new HashMap<Integer, EnchantmentData>();
            }
View Full Code Here

      }

      if(manaRequired == -1) {
        manaRequired = 0;
        for(EnchantmentData data : enchants) {
          Enchantment ench = Enchantment.enchantmentsList[data.enchant];
          manaRequired += (int) (5000F * ((15 - Math.min(15, ench.getWeight())) * 1.05F) * ((3F + data.level * data.level) * 0.25F) * (0.9F + enchants.size() * 0.05F));
        }
      } else if(mana >= manaRequired) {
        manaRequired = 0;
        for(int[] pylon : PYLON_LOCATIONS[getBlockMetadata()])
          ((TilePylon) worldObj.getTileEntity(xCoord + pylon[0], yCoord + pylon[1], zCoord + pylon[2])).activated = false;
View Full Code Here

    return false;
  }

  public boolean isEnchantmentValid(short id) {
    Enchantment ench = Enchantment.enchantmentsList[id];
    if(!ench.canApply(itemToEnchant) || !ench.type.canEnchantItem(itemToEnchant.getItem()))
      return false;

    for(EnchantmentData data : enchants) {
      Enchantment otherEnch = Enchantment.enchantmentsList[data.enchant];
      if(!otherEnch.canApplyTogether(ench) || !ench.canApplyTogether(otherEnch))
        return false;
    }

    return true;
  }
View Full Code Here

      ItemStack itemstack = player.getCurrentEquippedItem();

      if (itemstack == null) {
        throw new CommandException("commands.enchant.noItem", new Object[0]);
      } else {
        Enchantment enchantment = Enchantment.enchantmentsList[id];

        if (enchantment == null) {
          throw new NumberInvalidException("commands.enchant.notFound", new Object[] { Integer.valueOf(id) });
        }
        if (i < l) {
View Full Code Here

 
  @Override
  @SideOnly(Side.CLIENT)
  public void getSubItems(Item item, CreativeTabs creativeTab, List list) {
    ItemStack stack = new ItemStack(item, 1, 0);
    Enchantment ench = BetterStorageEnchantment.get("unlocking");
    if (ench != null) stack.addEnchantment(ench, 10);
    list.add(stack);
  }
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.