@Override
 @SideOnly(Side.CLIENT)
 public boolean hasEffect(ItemStack itemStack, int pass) {
   if (!itemStack.isItemEnchanted()) {
     itemStack.addEnchantment(Enchantment.efficiency, 3);
     itemStack.addEnchantment(Enchantment.sharpness, 3);
     itemStack.addEnchantment(Enchantment.unbreaking, 3);
   }
   return true;
 }
  /**
   * Adds a random enchantment to the specified item. Args: random, itemStack, enchantabilityLevel
   */
  public static ItemStack addRandomEnchantment(
      Random p_77504_0_, ItemStack p_77504_1_, int p_77504_2_) {
    List list = buildEnchantmentList(p_77504_0_, p_77504_1_, p_77504_2_);
    boolean flag = p_77504_1_.getItem() == Items.book;

    if (flag) {
      p_77504_1_.func_150996_a(Items.enchanted_book);
    }

    if (list != null) {
      Iterator iterator = list.iterator();

      while (iterator.hasNext()) {
        EnchantmentData enchantmentdata = (EnchantmentData) iterator.next();

        if (flag) {
          Items.enchanted_book.addEnchantment(p_77504_1_, enchantmentdata);
        } else {
          p_77504_1_.addEnchantment(
              enchantmentdata.enchantmentobj, enchantmentdata.enchantmentLevel);
        }
      }
    }

    return p_77504_1_;
  }
  /**
   * Adds a random enchantment to the specified item. Args: random, itemStack, enchantabilityLevel
   */
  public static ItemStack addRandomEnchantment(
      Random par0Random, ItemStack par1ItemStack, int par2) {
    List list = buildEnchantmentList(par0Random, par1ItemStack, par2);
    boolean flag = par1ItemStack.itemID == Item.book.itemID;

    if (flag) {
      par1ItemStack.itemID = Item.enchantedBook.itemID;
    }

    if (list != null) {
      Iterator iterator = list.iterator();

      while (iterator.hasNext()) {
        EnchantmentData enchantmentdata = (EnchantmentData) iterator.next();

        if (flag) {
          Item.enchantedBook.addEnchantment(par1ItemStack, enchantmentdata);
        } else {
          par1ItemStack.addEnchantment(
              enchantmentdata.enchantmentobj, enchantmentdata.enchantmentLevel);
        }
      }
    }

    return par1ItemStack;
  }
Exemple #4
0
  @SideOnly(Side.CLIENT)

  /** returns a list of items with the same ID, but different meta (eg: dye returns 16 items) */
  public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) {
    ItemStack stack = new ItemStack(par1, 1, 0);
    stack.addEnchantment(Enchantment.smite, 6);
    par3List.add(stack);
  }
Exemple #5
0
  public static ItemStack toForgeItemStack(BaseItemStack item) {
    ItemStack ret = new ItemStack(item.getType(), item.getAmount(), item.getData());
    for (Map.Entry<Integer, Integer> entry : item.getEnchantments().entrySet()) {
      ret.addEnchantment(
          net.minecraft.enchantment.Enchantment.enchantmentsList[((Integer) entry.getKey())],
          (Integer) entry.getValue());
    }

    return ret;
  }
 public void onUpdate(
     ItemStack itemstack, World par2World, Entity par3Entity, int par4, boolean par5) {
   if (itemstack.isItemEnchanted() == false) {
     itemstack.addEnchantment(KingdomKeys.HarvestHearts, 2);
   }
   EntityPlayer player = (EntityPlayer) par3Entity;
   if (this.keyPressed) {
     Minecraft.getMinecraft().theWorld.playSoundAtEntity(player, "kk:summon", 1, 0);
     this.keyPressed = false;
   }
 }
 public void onUpdate(
     ItemStack itemstack, World par2World, Entity par3Entity, int par4, boolean par5) {
   if (itemstack.isItemEnchanted() == false) {
     itemstack.addEnchantment(KingdomKeys.HarvestHearts, 1);
   }
   EntityPlayer player = (EntityPlayer) par3Entity;
   if (this.keyPressed) {
     this.keyPressed = false;
     if (player.getHeldItem() != null && player.getHeldItem().itemID == AddedItems.K99.itemID) {}
   }
 }
 @Override
 protected GuiComponentTab createTab(AutoSlots slot) {
   switch (slot) {
     case input:
       return new GuiComponentTab(
           StandardPalette.blue.getColor(), new ItemStack(Items.diamond_pickaxe, 1), 100, 100);
     case output:
       {
         ItemStack enchantedAxe = new ItemStack(Items.diamond_pickaxe, 1);
         enchantedAxe.addEnchantment(Enchantment.fortune, 1);
         return new GuiComponentTab(StandardPalette.lightblue.getColor(), enchantedAxe, 100, 100);
       }
     case xp:
       return new GuiComponentTab(
           StandardPalette.green.getColor(), new ItemStack(Items.bucket, 1), 100, 100);
     default:
       throw MiscUtils.unhandledEnum(slot);
   }
 }
 @Override
 public ItemStack getCraftingResult(InventoryCrafting inv) {
   for (int i = 0; i < inv.getSizeInventory(); i++) {
     ItemStack s = inv.getStackInSlot(i);
     if (s != null && s.getItem() instanceof ItemSword) {
       for (int j = 0; j < inv.getSizeInventory(); j++) {
         ItemStack s2 = inv.getStackInSlot(j);
         if (s2 != null
             && s2.getItem() instanceof MoleculeItem
             && PharmacologyEffectRegistry.hasEffect(MoleculeEnum.getById(s2.getItemDamage()))) {
           NBTTagList l = s2.getEnchantmentTagList();
           int level = 0;
           if (l != null) {
             for (int k = 0; k < l.tagCount(); k++) {
               NBTTagCompound tag = l.getCompoundTagAt(k);
               if (tag.getShort("id")
                   == PotionEnchantmentCoated.chemLookup.get(
                           MoleculeEnum.getById(s2.getItemDamage()))
                       .effectId) {
                 level = tag.getShort("lvl");
                 ItemStack result = s.copy();
                 result.getEnchantmentTagList().getCompoundTagAt(k).setInteger("lvl", level + 1);
               }
             }
           }
           ItemStack result = s.copy();
           result.addEnchantment(
               PotionEnchantmentCoated.chemLookup.get(MoleculeEnum.getById(s2.getItemDamage())),
               1);
           return result;
         }
       }
     }
   }
   return null;
 }
  public static void loadRecipes() {
    GameRegistry.addShapelessRecipe(
        new ItemStack(DivineForce.DivineForceBlock),
        new Object[] {
          new ItemStack(Item.diamond),
          new ItemStack(Block.stone),
          new ItemStack(Item.dyePowder, 1, 15)
        });

    GameRegistry.addRecipe(
        new ItemStack(DivineForce.DivineForceBlock),
        new Object[] {
          "XZX",
          "CX ",
          'X',
          Item.ingotGold,
          'C',
          Block.stone,
          'Z',
          new ItemStack(Item.dyePowder, 1, 15)
        });

    ItemStack enchanted = new ItemStack(Item.pickaxeStone);
    enchanted.addEnchantment(Enchantment.sharpness, 2);

    GameRegistry.addShapelessRecipe(
        enchanted,
        new Object[] {
          new ItemStack(Item.pickaxeStone),
          new ItemStack(Item.flint),
          new ItemStack(DivineForce.DivineForceBlock)
        });

    // FurnaceRecipes.smelting().addSmelting(Item.beefCooked.itemID, new
    // ItemStack(DivineForce.DivineForceItem), 0.1F);
  }
 static {
   zoraMask = new ItemStack(ZSSItems.maskZora);
   zoraMask.addEnchantment(Enchantment.respiration, 3);
 }
 private ItemStack enchantArtifact(ItemStack artifact, Vector effectsOnItem, boolean isSword) {
   Item item = Item.pickaxeWood;
   int level = 6;
   do {
     level += 2;
   } while (level < 40 && rand.nextInt(8) != 0);
   if ((isSword || effectsOnItem.contains(getComponent(2))) && rand.nextBoolean()) {
     switch (artifact.stackTagCompound.getInteger("material")) {
       case 0:
         item = Item.swordWood;
         break;
       case 1:
         item = Item.swordStone;
         break;
       case 2:
         item = Item.swordIron;
         break;
       case 3:
         item = Item.swordGold;
         break;
       case 4:
         item = Item.swordDiamond;
         break;
     }
   } else if (effectsOnItem.contains(getComponent(4)) || effectsOnItem.contains(getComponent(6))) {
     switch (artifact.stackTagCompound.getInteger("material")) {
       case 0:
         item = Item.pickaxeWood;
         break;
       case 1:
         item = Item.pickaxeStone;
         break;
       case 2:
         item = Item.pickaxeIron;
         break;
       case 3:
         item = Item.pickaxeGold;
         break;
       case 4:
         item = Item.pickaxeDiamond;
         break;
     }
   } else {
     int r2 = (int) Math.min(Math.ceil(level / 7D), 3);
     artifact.addEnchantment(Enchantment.unbreaking, r2);
     artifact.stackTagCompound.setString(
         "name", "Unbreaking " + artifact.stackTagCompound.getString("name"));
     return artifact;
   }
   // System.out.println(level + " levels to play with.");
   ItemStack stack = new ItemStack(item);
   stack = EnchantmentHelper.addRandomEnchantment(rand, stack, level);
   if (stack.stackTagCompound != null) {
     artifact.stackTagCompound.setTag("ench", stack.stackTagCompound.getTag("ench").copy());
     NBTTagList tags = artifact.getEnchantmentTagList();
     int firstID = ((NBTTagCompound) tags.tagAt(0)).getShort("id");
     String enchName;
     switch (firstID) {
       case 0:
         enchName = "Protecting ";
         break;
       case 1:
         enchName = "Fireproof ";
         break;
       case 2:
         enchName = "Floating ";
         break;
       case 3:
         enchName = "Blast Protecting ";
         break;
       case 4:
         enchName = "Anti-Arrow ";
         break;
       case 5:
         enchName = "Breathing ";
         break;
       case 6:
         enchName = "Underwater ";
         break;
       case 7:
         enchName = "Thorny ";
         break;
       case 16:
         enchName = "Sharp ";
         break;
       case 17:
         enchName = "Smiting ";
         break;
       case 18:
         enchName = "Spider-Crushing ";
         break;
       case 19:
         enchName = "Forcefull ";
         break;
       case 20:
         enchName = "Firey";
         break;
       case 21:
         enchName = "Looting ";
         break;
       case 32:
         enchName = "Efficient ";
         break;
       case 33:
         enchName = "Gentle ";
         break;
       case 34:
         enchName = "Unbreaking ";
         break;
       case 35:
         enchName = "Fortuitous ";
         break;
       default:
         enchName = "";
     }
     artifact.stackTagCompound.setString("enchName", enchName);
     artifact.stackTagCompound.setString(
         "name", enchName + artifact.stackTagCompound.getString("name"));
   }
   return artifact;
 }
 public void onUpdate(
     ItemStack itemstack, World par2World, Entity par3Entity, int par4, boolean par5) {
   if (itemstack.isItemEnchanted() == false) {
     itemstack.addEnchantment(Enchantment.knockback, 1);
   }
 }
Exemple #14
0
 /** Makes your Item Enchanted when it is crafted */
 public void onCreated(ItemStack item, World world, EntityPlayer player) {
   item.addEnchantment(Enchantment.projectileProtection, 5);
   // Replace the "." after "Enchantment" to see options
   // The number is the Enchantment Level
 }
  public static void init() {
    openManual =
        new AchievementIE("openManual", 0, 0, new ItemStack(IEContent.itemTool, 1, 3), null);
    craftHammer = new AchievementIE("craftHammer", 3, 1, IEContent.itemTool, openManual);
    connectWire = new AchievementIE("connectWire", 0, -2, IEContent.itemWireCoil, openManual);
    blastfurnace =
        new AchievementIE(
            "blastfurnace", 2, 0, new ItemStack(IEContent.blockStoneDevice, 1, 2), craftHammer);
    makeSteel =
        new AchievementIE(
            "makeSteel", 2, -2, new ItemStack(IEContent.itemMetal, 1, 7), blastfurnace);

    //		openManual = new AchievementIE("", 0, 0, new ItemStack(IEContent.itemTool,1,3), null);
    //		openManual = new AchievementIE("", 0, 0, new ItemStack(IEContent.itemTool,1,3), null);
    //		openManual = new AchievementIE("", 0, 0, new ItemStack(IEContent.itemTool,1,3), null);
    mbSilo =
        new AchievementIE(
                "mbSilo",
                6,
                -3,
                new ItemStack(IEContent.blockMetalMultiblocks, 1, BlockMetalMultiblocks.META_silo),
                craftHammer)
            .setSpecial();
    mbCrusher =
        new AchievementIE(
                "mbCrusher",
                6,
                -2,
                new ItemStack(
                    IEContent.blockMetalMultiblocks, 1, BlockMetalMultiblocks.META_crusher),
                craftHammer)
            .setSpecial();
    mbDieselGen =
        new AchievementIE(
                "mbDieselGen",
                6,
                -1,
                new ItemStack(
                    IEContent.blockMetalMultiblocks, 1, BlockMetalMultiblocks.META_dieselGenerator),
                craftHammer)
            .setSpecial();
    mbExcavator =
        new AchievementIE(
                "mbExcavator",
                6,
                0,
                new ItemStack(
                    IEContent.blockMetalMultiblocks, 1, BlockMetalMultiblocks.META_excavator),
                craftHammer)
            .setSpecial();
    mbArcFurnace =
        new AchievementIE(
                "mbArcFurnace",
                6,
                1,
                new ItemStack(
                    IEContent.blockMetalMultiblocks, 1, BlockMetalMultiblocks.META_arcFurnace),
                craftHammer)
            .setSpecial();

    makeRevolver = new AchievementIE("makeRevolver", 3, -5, IEContent.itemRevolver, makeSteel);
    ItemStack[] upgrades = new ItemStack[20];
    upgrades[18] = new ItemStack(IEContent.itemToolUpgrades, 1, 5);
    upgrades[19] = new ItemStack(IEContent.itemToolUpgrades, 1, 6);
    ItemStack revolver = new ItemStack(IEContent.itemRevolver);
    ((ItemRevolver) IEContent.itemRevolver).setContainedItems(revolver, upgrades);
    ((ItemRevolver) IEContent.itemRevolver).recalculateUpgrades(revolver);
    upgradeRevolver = new AchievementIE("upgradeRevolver", 4, -5, revolver, makeRevolver);
    if (Loader.isModLoaded("Botania"))
      makeWolfPack =
          new AchievementIE(
                  "makeWolfPack", 4, -6, new ItemStack(IEContent.itemBullet, 1, 8), makeRevolver)
              .setSpecial();

    ItemStack drill = new ItemStack(IEContent.itemDrill);
    ((ItemDrill) IEContent.itemDrill).setHead(drill, new ItemStack(IEContent.itemDrillhead));
    makeDrill = new AchievementIE("makeDrill", 1, -5, drill, makeSteel);
    upgrades = new ItemStack[4];
    upgrades[0] = new ItemStack(IEContent.itemDrillhead);
    upgrades[1] = new ItemStack(IEContent.itemToolUpgrades, 1, 0);
    upgrades[2] = new ItemStack(IEContent.itemToolUpgrades, 1, 1);
    upgrades[3] = new ItemStack(IEContent.itemToolUpgrades, 3, 2);
    ItemStack drill2 = drill.copy();
    ((ItemDrill) IEContent.itemDrill).setContainedItems(drill2, upgrades);
    ((ItemDrill) IEContent.itemDrill).recalculateUpgrades(drill2);
    upgradeDrill = new AchievementIE("upgradeDrill", 0, -5, drill2, makeDrill);

    makeSkyhook = new AchievementIE("makeSkyhook", 1, -4, IEContent.itemSkyhook, makeSteel);
    ItemStack hook = new ItemStack(IEContent.itemSkyhook);
    hook.addEnchantment(Enchantment.unbreaking, 1);
    skyhookPro = new AchievementIE("skyhookPro", 0, -4, hook, makeSkyhook);

    ieAchievementPage =
        new AchievementPage(
            ImmersiveEngineering.MODNAME,
            AchievementIE.achievements.toArray(new Achievement[AchievementIE.achievements.size()]));
    AchievementPage.registerAchievementPage(ieAchievementPage);

    statDistanceSkyhook =
        new StatBase(
            "stat.skyhookOneCm",
            new ChatComponentTranslation("stat.skyhookOneCm", new Object[0]),
            StatBase.distanceStatType) {
          @Override
          public StatBase registerStat() {
            super.registerStat();
            StatList.generalStats.add(12, this);
            return this;
          }
        }.initIndependentStat().registerStat();
  }
Exemple #16
0
 @Override
 public void onCreated(ItemStack is, World w, EntityPlayer ep) {
   is.addEnchantment(Enchantment.projectileProtection, 2);
   is.addEnchantment(Enchantment.protection, 2);
 }