Search in sources :

Example 36 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 37 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 38 with Enchantment

use of net.minecraft.enchantment.Enchantment in project SilentGems by SilentChaos512.

the class ItemEnchantmentToken method mergeEnchantmentLists.

public boolean mergeEnchantmentLists(Map<Enchantment, Integer> ench1, Map<Enchantment, Integer> ench2) {
    int level, newLevel;
    // Add enchantments from second list to first...
    for (Enchantment enchantment : ench2.keySet()) {
        level = newLevel = ench2.get(enchantment);
        // If first list contains the enchantment, try increasing the level.
        if (ench1.containsKey(enchantment)) {
            newLevel = ench1.get(enchantment) + level;
            // Level too high?
            if (newLevel > enchantment.getMaxLevel()) {
                return false;
            }
        }
        ench1.put(enchantment, newLevel);
    }
    return true;
}
Also used : Enchantment(net.minecraft.enchantment.Enchantment)

Example 39 with Enchantment

use of net.minecraft.enchantment.Enchantment in project SilentGems by SilentChaos512.

the class ItemEnchantmentToken method getModelKey.

public String getModelKey(ItemStack stack) {
    Map<Enchantment, Integer> enchMap = getEnchantments(stack);
    String key = KEY_EMPTY;
    if (!enchMap.isEmpty()) {
        Enchantment ench = enchMap.keySet().iterator().next();
        if (ench == null || ench.type == null)
            return KEY_UNKNOWN;
        try {
            switch(ench.type) {
                case ALL:
                case BREAKABLE:
                    return KEY_ANY;
                case ARMOR:
                case ARMOR_CHEST:
                case ARMOR_FEET:
                case ARMOR_HEAD:
                case ARMOR_LEGS:
                case WEARABLE:
                    return KEY_ARMOR;
                case BOW:
                    return KEY_BOW;
                case DIGGER:
                    return KEY_DIGGER;
                case FISHING_ROD:
                    return KEY_FISHING_ROD;
                case WEAPON:
                    return KEY_WEAPON;
                default:
                    return KEY_UNKNOWN;
            }
        } catch (ArrayIndexOutOfBoundsException ex) {
            // Some mod is causing a crash I can't reproduce. Try to catch it and log any information possible.
            if (!loggedIssue139Catch) {
                loggedIssue139Catch = true;
                SilentGems.logHelper.severe("Caught an odd exception in ItemEnchantmentToken#getModelKey. This will only be logged once.");
                SilentGems.logHelper.info("Offending token: " + stack);
                SilentGems.logHelper.info("Offending enchantment: " + ench + " (" + ench.getName() + ")");
                ex.printStackTrace();
                return KEY_EMPTY;
            }
        }
    }
    return key;
}
Also used : Enchantment(net.minecraft.enchantment.Enchantment)

Example 40 with Enchantment

use of net.minecraft.enchantment.Enchantment in project SilentGems by SilentChaos512.

the class ItemEnchantmentToken method addInformation.

// =========================
// Item and ItemSL overrides
// =========================
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) {
    LocalizationHelper loc = SilentGems.localizationHelper;
    Map<Enchantment, Integer> enchants = getEnchantments(stack);
    if (enchants.size() == 1) {
        Enchantment ench = enchants.keySet().iterator().next();
        list.add(loc.getItemSubText(itemName, "maxLevel", ench.getMaxLevel()));
        // Recipe info
        if (KeyTracker.isControlDown()) {
            list.add(loc.getItemSubText(itemName, "materials"));
            String recipeString = recipeMap.get(ench);
            if (recipeString != null && !recipeString.isEmpty()) {
                for (String str : recipeString.split(";")) {
                    list.add("  " + str);
                }
            }
        } else {
            list.add(loc.getItemSubText(itemName, "pressCtrl"));
        }
        // Debug info
        if (KeyTracker.isAltDown()) {
            list.add(TextFormatting.DARK_GRAY + ench.getRegistryName().toString());
        // list.add(TextFormatting.DARK_GRAY + "EnchID: " + ench.getEnchantmentID(ench));
        }
    }
    // Enchantment list
    for (Entry<Enchantment, Integer> entry : enchants.entrySet()) {
        Enchantment e = entry.getKey();
        list.add(e.getTranslatedName(entry.getValue()));
        String descKey = e.getName() + ".desc";
        String desc = loc.getLocalizedString(descKey);
        if (!desc.equals(descKey))
            list.add(TextFormatting.DARK_GRAY + "  " + desc);
    }
}
Also used : Enchantment(net.minecraft.enchantment.Enchantment) LocalizationHelper(net.silentchaos512.lib.util.LocalizationHelper)

Aggregations

Enchantment (net.minecraft.enchantment.Enchantment)55 ItemStack (net.minecraft.item.ItemStack)32 ArrayList (java.util.ArrayList)10 Map (java.util.Map)9 Item (net.minecraft.item.Item)9 EnchantmentData (net.minecraft.enchantment.EnchantmentData)8 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)7 NBTTagList (net.minecraft.nbt.NBTTagList)7 HashMap (java.util.HashMap)6 Iterator (java.util.Iterator)6 List (java.util.List)4 EntityLivingBase (net.minecraft.entity.EntityLivingBase)4 ResourceLocation (net.minecraft.util.ResourceLocation)4 Block (net.minecraft.block.Block)3 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)3 EnchantmentHelper (net.minecraft.enchantment.EnchantmentHelper)3 Entity (net.minecraft.entity.Entity)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 ItemEnchantedBook (net.minecraft.item.ItemEnchantedBook)3 ImmutableList (com.google.common.collect.ImmutableList)2