Java Code Examples for net.minecraft.enchantment.Enchantment#getMaxLevel()

The following examples show how to use net.minecraft.enchantment.Enchantment#getMaxLevel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemUtil.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
public static boolean isIllegalEnchant(Enchantment enc, short lvl) {
    final int maxPossibleLevel = enc.getMaxLevel();
    if (lvl == 0 || lvl > maxPossibleLevel)
        return true;

    return lvl == Short.MAX_VALUE;
}
 
Example 2
Source File: InfusionEnchantmentRecipe.java    From AdvancedMod with GNU General Public License v3.0 4 votes vote down vote up
/**
     * 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;
    }
 
Example 3
Source File: InfusionEnchantmentRecipe.java    From Chisel-2 with GNU General Public License v2.0 4 votes vote down vote up
/**
     * 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;
    }
 
Example 4
Source File: InfusionEnchantmentRecipe.java    From GardenCollection with MIT License 4 votes vote down vote up
/**
     * 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;
    }
 
Example 5
Source File: InfusionEnchantmentRecipe.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 4 votes vote down vote up
/**
     * 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;
    }
 
Example 6
Source File: InfusionEnchantmentRecipe.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
/**
     * 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;
    }
 
Example 7
Source File: EnchantmentUtils.java    From OpenModsLib with MIT License 4 votes vote down vote up
public static void addAllBooks(Enchantment enchantment, List<ItemStack> items) {
	for (int i = enchantment.getMinLevel(); i <= enchantment.getMaxLevel(); i++)
		items.add(ItemEnchantedBook.getEnchantedItemStack(new EnchantmentData(enchantment, i)));
}