Java Code Examples for net.minecraft.item.ItemStack#isItemEnchanted()
The following examples show how to use
net.minecraft.item.ItemStack#isItemEnchanted() .
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 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 2
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 3
Source File: GT_Rockcutter_Item.java From bartworks with MIT License | 5 votes |
public void onUpdate(ItemStack aStack, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { if (!ElectricItem.manager.canUse(aStack, 500 * this.multi)) { if (aStack.isItemEnchanted()) { aStack.getTagCompound().removeTag("ench"); } } else if (!aStack.isItemEnchanted()) { aStack.addEnchantment(Enchantment.silkTouch, 3); } }
Example 4
Source File: GTHelperStack.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
public static int getItemStackEnchantmentLevel(ItemStack stack) { if (!stack.isEmpty() && stack.isItemEnchanted() && !(stack.getItem() instanceof IElectricTool)) { int level = 0; for (Map.Entry<Enchantment, Integer> entry : EnchantmentHelper.getEnchantments(stack).entrySet()) { level = level + entry.getValue(); } return level; } return 0; }
Example 5
Source File: ProxyCommon.java From WearableBackpacks with MIT License | 5 votes |
/** Called when a mob spawns with a backpack with a 1 tick delay. */ private void onSpawnedWith(EntityLivingBase entity, BackpackCapability backpack, BackpackEntry entry) { ItemStack stack = new ItemStack(entry.getBackpackItem()); if (entry.colorRange != null) // Set a random color! NbtUtils.set(stack, entry.colorRange.getRandom(), "display", "color"); // Set damage to a random amount (25% - 75%). int maxDamage = stack.getMaxDamage(); int damage = maxDamage / 4 + ((maxDamage / 2 > 0) ? entity.world.rand.nextInt(maxDamage / 2) : 0); stack.setItemDamage(damage); if (BackpackHelper.equipAsChestArmor) { // If the entity spawned with enchanted armor, // then move over all compatible enchantments. ItemStack armor = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST); if ((armor != null) && armor.isItemEnchanted()) { NBTTagList enchList = armor.getEnchantmentTagList(); for (int i = 0; i < enchList.tagCount(); ++i) { NBTTagCompound enchTag = enchList.getCompoundTagAt(i); Enchantment enchantment = Enchantment.getEnchantmentByID(enchTag.getShort("id")); // If the enchantment doesn't work with the backpack, remove it. if (!enchantment.canApply(stack)) enchList.removeTag(i--); } if (enchList.tagCount() > 0) NbtUtils.set(stack, enchList, "ench"); } } IBackpackType type = entry.getBackpackItem(); IBackpackData data = type.createBackpackData(stack); BackpackHelper.setEquippedBackpack(entity, stack, data); type.onSpawnedWith(entity, backpack, entry.lootTable); backpack.spawnWith = null; backpack.mayDespawn = true; }
Example 6
Source File: RendererBackpack.java From WearableBackpacks with MIT License | 5 votes |
private static void renderBackpack(IBackpack backpack, float ticks, boolean renderStraps) { ItemStack stack = backpack.getStack(); int color = ProxyClient.ITEM_COLOR.colorMultiplier(stack, 0); BlockModelRenderer renderer = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer(); Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); float r = (color >> 16 & 0xFF) / 255.0F; float g = (color >> 8 & 0xFF) / 255.0F; float b = (color & 0xFF) / 255.0F; renderModel(backpack, renderer, ticks, renderStraps, r, g, b, false); if (stack.isItemEnchanted()) renderEnchanted(backpack, renderer, ticks, renderStraps); }
Example 7
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 8
Source File: GTItemComponent.java From GT-Classic with GNU Lesser General Public License v3.0 | 4 votes |
@SideOnly(Side.CLIENT) @Override public boolean hasEffect(ItemStack stack) { return this == GTItems.fuelBinderMagic ? true : stack.isItemEnchanted(); }