Java Code Examples for net.minecraft.enchantment.EnchantmentHelper#getEnchantments()
The following examples show how to use
net.minecraft.enchantment.EnchantmentHelper#getEnchantments() .
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: ItemSheathKatana.java From Sakura_mod with MIT License | 5 votes |
public ItemStack setKatana(ItemStack blade) { ItemStack result = new ItemStack(katana,1); result.setItemDamage(blade.getItemDamage()); if(blade.isItemEnchanted()){ Map<Enchantment, Integer> map = EnchantmentHelper.getEnchantments(blade); for(Enchantment ench : map.keySet()){ result.addEnchantment(ench, map.get(ench)); } } return result; }
Example 2
Source File: EntityInfo.java From fabric-carpet with MIT License | 5 votes |
private static String display_item(ItemStack item) { if (item == null) { return null; } if (item.isEmpty()) // func_190926_b() { return null; } // func_190916_E() String stackname = item.getCount()>1?String.format("%dx%s",item.getCount(), item.getName().getString()):item.getName().getString(); if (item.isDamaged()) { stackname += String.format(" %d/%d", item.getMaxUseTime()-item.getDamage(), item.getMaxUseTime()); } if (item.hasEnchantments()) { stackname += " ( "; Map<Enchantment, Integer> enchants = EnchantmentHelper.getEnchantments(item); for (Enchantment e: enchants.keySet()) { int level = enchants.get(e); String enstring = e.getName(level).getString(); stackname += enstring+" "; } stackname += ")"; } return stackname; }
Example 3
Source File: InfusionEnchantmentRecipe.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public int calcInstability(ItemStack recipeInput) { int i = 0; Map map1 = EnchantmentHelper.getEnchantments(recipeInput); Iterator iterator = map1.keySet().iterator(); while (iterator.hasNext()) { int j1 = ((Integer)iterator.next()).intValue(); i += EnchantmentHelper.getEnchantmentLevel(j1, recipeInput); } return (i/2) + instability; }
Example 4
Source File: PressureChamberPressureEnchantHandler.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@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) { //Map map = EnchantmentHelper.getEnchantments(inputStack); // Iterator toolEnchantIterator = map.keySet().iterator(); // while(toolEnchantIterator.hasNext()){ // 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; }
Example 5
Source File: ItemSheathKatana.java From Sakura_mod with MIT License | 5 votes |
public ItemStack setBlade(ItemStack blade) { ItemStack result = new ItemStack(this,1); result.setItemDamage(blade.getItemDamage()); if(blade.isItemEnchanted()){ Map<Enchantment, Integer> map = EnchantmentHelper.getEnchantments(blade); for(Enchantment ench : map.keySet()){ result.addEnchantment(ench, map.get(ench)); } } return result; }
Example 6
Source File: InfusionEnchantmentRecipe.java From AdvancedMod with GNU General Public License v3.0 | 5 votes |
public int calcInstability(ItemStack recipeInput) { int i = 0; Map map1 = EnchantmentHelper.getEnchantments(recipeInput); Iterator iterator = map1.keySet().iterator(); while (iterator.hasNext()) { int j1 = ((Integer)iterator.next()).intValue(); i += EnchantmentHelper.getEnchantmentLevel(j1, recipeInput); } return (i/2) + instability; }
Example 7
Source File: InfusionEnchantmentRecipe.java From AdvancedMod with GNU General Public License v3.0 | 5 votes |
public float getEssentiaMod(ItemStack recipeInput) { float mod = EnchantmentHelper.getEnchantmentLevel(enchantment.effectId, recipeInput); Map map1 = EnchantmentHelper.getEnchantments(recipeInput); Iterator iterator = map1.keySet().iterator(); while (iterator.hasNext()) { int j1 = ((Integer)iterator.next()).intValue(); if (j1 != enchantment.effectId) mod += EnchantmentHelper.getEnchantmentLevel(j1, recipeInput) * .1f; } return mod; }
Example 8
Source File: ItemFocusBasic.java From AdvancedMod with GNU General Public License v3.0 | 5 votes |
/** * Just insert two alphanumeric characters before this string in your focus item class */ @Override public String getSortingHelper(ItemStack itemstack) { Map<Integer,Integer> ench = EnchantmentHelper.getEnchantments(itemstack); String out=""; for (Integer lvl:ench.values()) { out = out + lvl + ""; } return out; }
Example 9
Source File: InfusionEnchantmentRecipe.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public float getEssentiaMod(ItemStack recipeInput) { float mod = EnchantmentHelper.getEnchantmentLevel(enchantment.effectId, recipeInput); Map map1 = EnchantmentHelper.getEnchantments(recipeInput); Iterator iterator = map1.keySet().iterator(); while (iterator.hasNext()) { int j1 = ((Integer)iterator.next()).intValue(); if (j1 != enchantment.effectId) mod += EnchantmentHelper.getEnchantmentLevel(j1, recipeInput) * .1f; } return mod; }
Example 10
Source File: InfusionEnchantmentRecipe.java From ForbiddenMagic with Do What The F*ck You Want To Public License | 5 votes |
public float getEssentiaMod(ItemStack recipeInput) { float mod = EnchantmentHelper.getEnchantmentLevel(enchantment.effectId, recipeInput); Map map1 = EnchantmentHelper.getEnchantments(recipeInput); Iterator iterator = map1.keySet().iterator(); while (iterator.hasNext()) { int j1 = ((Integer)iterator.next()).intValue(); if (j1 != enchantment.effectId) mod += EnchantmentHelper.getEnchantmentLevel(j1, recipeInput) * .1f; } return mod; }
Example 11
Source File: InfusionEnchantmentRecipe.java From Chisel-2 with GNU General Public License v2.0 | 5 votes |
public int calcInstability(ItemStack recipeInput) { int i = 0; Map map1 = EnchantmentHelper.getEnchantments(recipeInput); Iterator iterator = map1.keySet().iterator(); while (iterator.hasNext()) { int j1 = ((Integer)iterator.next()).intValue(); i += EnchantmentHelper.getEnchantmentLevel(j1, recipeInput); } return (i/2) + instability; }
Example 12
Source File: InfusionEnchantmentRecipe.java From Chisel-2 with GNU General Public License v2.0 | 5 votes |
public float getEssentiaMod(ItemStack recipeInput) { float mod = EnchantmentHelper.getEnchantmentLevel(enchantment.effectId, recipeInput); Map map1 = EnchantmentHelper.getEnchantments(recipeInput); Iterator iterator = map1.keySet().iterator(); while (iterator.hasNext()) { int j1 = ((Integer)iterator.next()).intValue(); if (j1 != enchantment.effectId) mod += EnchantmentHelper.getEnchantmentLevel(j1, recipeInput) * .1f; } return mod; }
Example 13
Source File: InfusionEnchantmentRecipe.java From ForbiddenMagic with Do What The F*ck You Want To Public License | 5 votes |
public int calcInstability(ItemStack recipeInput) { int i = 0; Map map1 = EnchantmentHelper.getEnchantments(recipeInput); Iterator iterator = map1.keySet().iterator(); while (iterator.hasNext()) { int j1 = ((Integer)iterator.next()).intValue(); i += EnchantmentHelper.getEnchantmentLevel(j1, recipeInput); } return (i/2) + instability; }
Example 14
Source File: InfusionEnchantmentRecipe.java From GardenCollection with MIT License | 5 votes |
public int calcInstability(ItemStack recipeInput) { int i = 0; Map map1 = EnchantmentHelper.getEnchantments(recipeInput); Iterator iterator = map1.keySet().iterator(); while (iterator.hasNext()) { int j1 = ((Integer)iterator.next()).intValue(); i += EnchantmentHelper.getEnchantmentLevel(j1, recipeInput); } return (i/2) + instability; }
Example 15
Source File: InfusionEnchantmentRecipe.java From GardenCollection with MIT License | 5 votes |
public float getEssentiaMod(ItemStack recipeInput) { float mod = EnchantmentHelper.getEnchantmentLevel(enchantment.effectId, recipeInput); Map map1 = EnchantmentHelper.getEnchantments(recipeInput); Iterator iterator = map1.keySet().iterator(); while (iterator.hasNext()) { int j1 = ((Integer)iterator.next()).intValue(); if (j1 != enchantment.effectId) mod += EnchantmentHelper.getEnchantmentLevel(j1, recipeInput) * .1f; } return mod; }
Example 16
Source File: InfusionEnchantmentRecipe.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
/** * 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 17
Source File: InfusionEnchantmentRecipe.java From ForbiddenMagic with Do What The F*ck You Want To Public License | 4 votes |
/** * 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 18
Source File: InfusionEnchantmentRecipe.java From GardenCollection with MIT License | 4 votes |
/** * 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 19
Source File: InfusionEnchantmentRecipe.java From Chisel-2 with GNU General Public License v2.0 | 4 votes |
/** * 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 20
Source File: InfusionEnchantmentRecipe.java From AdvancedMod with GNU General Public License v3.0 | 4 votes |
/** * 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; }