Search in sources :

Example 6 with Enchantment

use of net.minecraft.enchantment.Enchantment in project RFToolsDimensions by McJty.

the class ModCrafting method createEnchantedItem.

public static ItemStack createEnchantedItem(Item item, Enchantment enchantment, int amount) {
    ItemStack stack = new ItemStack(item);
    Map<Enchantment, Integer> enchant = new HashMap<>();
    enchant.put(enchantment, amount);
    EnchantmentHelper.setEnchantments(enchant, stack);
    return stack;
}
Also used : HashMap(java.util.HashMap) ItemStack(net.minecraft.item.ItemStack) Enchantment(net.minecraft.enchantment.Enchantment)

Example 7 with Enchantment

use of net.minecraft.enchantment.Enchantment in project BetterStorage by copygirl.

the class ItemMasterKey method getSubItems.

@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);
}
Also used : ItemStack(net.minecraft.item.ItemStack) Enchantment(net.minecraft.enchantment.Enchantment) BetterStorageEnchantment(net.mcft.copy.betterstorage.api.BetterStorageEnchantment) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 8 with Enchantment

use of net.minecraft.enchantment.Enchantment in project BetterStorage by copygirl.

the class EnchantmentBetterStorage method initialize.

public static void initialize() {
    Map<String, EnumEnchantmentType> types = BetterStorageEnchantment.enchantmentTypes;
    Map<String, Enchantment> enchs = BetterStorageEnchantment.enchantments;
    // Add key enchantments
    if (BetterStorageItems.key != null) {
        EnumEnchantmentType key = EnumHelper.addEnchantmentType("key");
        EnchantmentBetterStorage unlocking = conditialNew("unlocking", key, GlobalConfig.enchUnlockingId, 8, 5, 5, 10, 30, 0);
        EnchantmentBetterStorage lockpicking = conditialNew("lockpicking", key, GlobalConfig.enchLockpickingId, 6, 5, 5, 8, 30, 0);
        EnchantmentBetterStorage morphing = conditialNew("morphing", key, GlobalConfig.enchMorphingId, 1, 5, 10, 12, 30, 0);
        if (lockpicking != null)
            lockpicking.setIncompatible(morphing);
        if (morphing != null)
            morphing.setIncompatible(lockpicking);
        types.put("key", key);
        enchs.put("unlocking", unlocking);
        enchs.put("lockpicking", lockpicking);
        enchs.put("morphing", morphing);
    }
    // Add lock enchantments
    if (BetterStorageItems.lock != null) {
        EnumEnchantmentType lock = EnumHelper.addEnchantmentType("lock");
        EnchantmentBetterStorage persistance = conditialNew("persistance", lock, GlobalConfig.enchPersistanceId, 20, 5, 1, 8, 30, 0);
        EnchantmentBetterStorage security = conditialNew("security", lock, GlobalConfig.enchSecurityId, 16, 5, 1, 10, 30, 0);
        EnchantmentBetterStorage shock = conditialNew("shock", lock, GlobalConfig.enchShockId, 5, 3, 5, 15, 30, 0);
        EnchantmentBetterStorage trigger = conditialNew("trigger", lock, GlobalConfig.enchTriggerId, 10, 1, 15, 0, 30, 0);
        types.put("lock", lock);
        enchs.put("persistance", persistance);
        enchs.put("security", security);
        enchs.put("shock", shock);
        enchs.put("trigger", trigger);
    }
}
Also used : Enchantment(net.minecraft.enchantment.Enchantment) BetterStorageEnchantment(net.mcft.copy.betterstorage.api.BetterStorageEnchantment) EnumEnchantmentType(net.minecraft.enchantment.EnumEnchantmentType)

Example 9 with Enchantment

use of net.minecraft.enchantment.Enchantment in project PneumaticCraft by MineMaarten.

the class PressureChamberPressureEnchantHandler method isValidRecipe.

@Override
public ItemStack[] isValidRecipe(ItemStack[] inputStacks) {
    List<ItemStack> enchantedBooks = new ArrayList<ItemStack>();
    for (ItemStack book : inputStacks) {
        if (book.getItem() == Items.enchanted_book)
            enchantedBooks.add(book);
    }
    if (enchantedBooks.size() == 0)
        return null;
    for (ItemStack inputStack : inputStacks) {
        if ((inputStack.isItemEnchantable() || inputStack.isItemEnchanted()) && inputStack.getItem() != Items.enchanted_book) {
            //    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 };
                    }
                }
            }
        //  }
        }
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ItemStack(net.minecraft.item.ItemStack) Enchantment(net.minecraft.enchantment.Enchantment) Map(java.util.Map)

Example 10 with Enchantment

use of net.minecraft.enchantment.Enchantment in project ArsMagica2 by Mithion.

the class InfusionEnchantmentRecipe method matches.

/**
     * Used to check if a recipe matches current crafting inventory
     * @param player 
     */
public boolean matches(ArrayList<ItemStack> input, ItemStack central, World world, EntityPlayer player) {
    if (research.length() > 0 && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), research)) {
        return false;
    }
    if (!enchantment.canApply(central) || !central.getItem().isItemTool(central)) {
        return false;
    }
    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;
    ArrayList<ItemStack> ii = new ArrayList<ItemStack>();
    for (ItemStack is : input) {
        ii.add(is.copy());
    }
    for (ItemStack comp : components) {
        boolean b = false;
        for (int a = 0; a < ii.size(); a++) {
            i2 = ii.get(a).copy();
            if (comp.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
                i2.setItemDamage(OreDictionary.WILDCARD_VALUE);
            }
            if (areItemStacksEqual(i2, comp, true)) {
                ii.remove(a);
                b = true;
                break;
            }
        }
        if (!b)
            return false;
    }
    //		System.out.println(ii.size());
    return ii.size() == 0 ? true : false;
}
Also used : Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) Enchantment(net.minecraft.enchantment.Enchantment) ItemStack(net.minecraft.item.ItemStack) Map(java.util.Map)

Aggregations

Enchantment (net.minecraft.enchantment.Enchantment)12 ItemStack (net.minecraft.item.ItemStack)10 Iterator (java.util.Iterator)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 BetterStorageEnchantment (net.mcft.copy.betterstorage.api.BetterStorageEnchantment)2 EnchantmentData (net.minecraft.enchantment.EnchantmentData)2 ItemEnchantedBook (net.minecraft.item.ItemEnchantedBook)2 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 HashMap (java.util.HashMap)1 Nullable (javax.annotation.Nullable)1 EnumEnchantmentType (net.minecraft.enchantment.EnumEnchantmentType)1 Item (net.minecraft.item.Item)1 MerchantRecipe (net.minecraft.village.MerchantRecipe)1 ContainerSearcher (pneumaticCraft.common.inventory.ContainerSearcher)1