예제 #1
0
  /**
   * Initializes statistics related to craftable items. Is only called after both block and item
   * stats have been initialized.
   */
  public static void initCraftableStats() {
    if (blockStatsInitialized && itemStatsInitialized) {
      HashSet var0 = new HashSet();
      Iterator var1 = CraftingManager.getInstance().getRecipeList().iterator();

      while (var1.hasNext()) {
        IRecipe var2 = (IRecipe) var1.next();
        var0.add(Integer.valueOf(var2.getRecipeOutput().itemID));
      }

      var1 = FurnaceRecipes.smelting().getSmeltingList().values().iterator();

      while (var1.hasNext()) {
        ItemStack var4 = (ItemStack) var1.next();
        var0.add(Integer.valueOf(var4.itemID));
      }

      objectCraftStats = new StatBase[32000];
      var1 = var0.iterator();

      while (var1.hasNext()) {
        Integer var5 = (Integer) var1.next();

        if (Item.itemsList[var5.intValue()] != null) {
          String var3 =
              StatCollector.translateToLocalFormatted(
                  "stat.craftItem", new Object[] {Item.itemsList[var5.intValue()].getStatName()});
          objectCraftStats[var5.intValue()] =
              (new StatCrafting(16842752 + var5.intValue(), var3, var5.intValue())).registerStat();
        }
      }

      replaceAllSimilarBlocks(objectCraftStats);
    }
  }
  public ItemStack findMatchingRecipe(InventoryCrafting inventorycrafting) {
    for (int i = 0; i < recipes.size(); i++) {
      IRecipe irecipe = (IRecipe) recipes.get(i);
      if (irecipe.matches(inventorycrafting)) {
        return irecipe.getCraftingResult(inventorycrafting);
      }
    }

    return null;
  }
예제 #3
0
  public ItemStack craft(InventoryCrafting inventorycrafting, World world) {
    int i = 0;
    ItemStack itemstack = null;
    ItemStack itemstack1 = null;

    int j;

    for (j = 0; j < inventorycrafting.getSize(); ++j) {
      ItemStack itemstack2 = inventorycrafting.getItem(j);

      if (itemstack2 != null) {
        if (i == 0) {
          itemstack = itemstack2;
        }

        if (i == 1) {
          itemstack1 = itemstack2;
        }

        ++i;
      }
    }

    if (i == 2
        && itemstack.id == itemstack1.id
        && itemstack.count == 1
        && itemstack1.count == 1
        && Item.byId[itemstack.id].usesDurability()) {
      Item item = Item.byId[itemstack.id];
      int k = item.getMaxDurability() - itemstack.j();
      int l = item.getMaxDurability() - itemstack1.j();
      int i1 = k + l + item.getMaxDurability() * 5 / 100;
      int j1 = item.getMaxDurability() - i1;

      if (j1 < 0) {
        j1 = 0;
      }

      return new ItemStack(itemstack.id, 1, j1);
    } else {
      for (j = 0; j < this.recipes.size(); ++j) {
        IRecipe irecipe = (IRecipe) this.recipes.get(j);

        if (irecipe.a(inventorycrafting, world)) {
          return irecipe.a(inventorycrafting);
        }
      }

      return null;
    }
  }
  public ItemStack findMatchingRecipe(InventoryCrafting par1InventoryCrafting, World par2World) {
    int i = 0;
    ItemStack itemstack = null;
    ItemStack itemstack1 = null;
    int j;

    for (j = 0; j < par1InventoryCrafting.getSizeInventory(); ++j) {
      ItemStack itemstack2 = par1InventoryCrafting.getStackInSlot(j);

      if (itemstack2 != null) {
        if (i == 0) {
          itemstack = itemstack2;
        }

        if (i == 1) {
          itemstack1 = itemstack2;
        }

        ++i;
      }
    }

    if (i == 2
        && itemstack.getItem() == itemstack1.getItem()
        && itemstack.stackSize == 1
        && itemstack1.stackSize == 1
        && itemstack.getItem().isRepairable()) {
      Item item = itemstack.getItem();
      int j1 = item.getMaxDamage() - itemstack.getItemDamageForDisplay();
      int k = item.getMaxDamage() - itemstack1.getItemDamageForDisplay();
      int l = j1 + k + item.getMaxDamage() * 5 / 100;
      int i1 = item.getMaxDamage() - l;

      if (i1 < 0) {
        i1 = 0;
      }

      return new ItemStack(itemstack.getItem(), 1, i1);
    } else {
      for (j = 0; j < this.recipes.size(); ++j) {
        IRecipe irecipe = (IRecipe) this.recipes.get(j);

        if (irecipe.matches(par1InventoryCrafting, par2World)) {
          return irecipe.getCraftingResult(par1InventoryCrafting);
        }
      }

      return null;
    }
  }
예제 #5
0
  public ItemStack findMatchingRecipe(InventoryCrafting inventorycrafting) {
    int i = 0;
    ItemStack itemstack = null;
    ItemStack itemstack1 = null;
    for (int j = 0; j < inventorycrafting.getSizeInventory(); j++) {
      ItemStack itemstack2 = inventorycrafting.getStackInSlot(j);
      if (itemstack2 == null) {
        continue;
      }
      if (i == 0) {
        itemstack = itemstack2;
      }
      if (i == 1) {
        itemstack1 = itemstack2;
      }
      i++;
    }

    if (i == 2
        && itemstack.itemID == itemstack1.itemID
        && itemstack.stackSize == 1
        && itemstack1.stackSize == 1
        && Item.itemsList[itemstack.itemID].isDamageable()) {
      Item item = Item.itemsList[itemstack.itemID];
      int l = item.getMaxDamage() - itemstack.getItemDamageForDisplay();
      int i1 = item.getMaxDamage() - itemstack1.getItemDamageForDisplay();
      int j1 = l + i1 + (item.getMaxDamage() * 10) / 100;
      int k1 = item.getMaxDamage() - j1;
      if (k1 < 0) {
        k1 = 0;
      }
      return new ItemStack(itemstack.itemID, 1, k1);
    }
    for (int k = 0; k < recipes.size(); k++) {
      IRecipe irecipe = (IRecipe) recipes.get(k);
      if (irecipe.matches(inventorycrafting)) {
        return irecipe.getCraftingResult(inventorycrafting);
      }
    }

    return null;
  }
예제 #6
0
  public static void func_25091_c() {
    if (!field_25101_D || !field_25099_E) {
      return;
    }
    HashSet hashset = new HashSet();
    IRecipe irecipe;
    for (Iterator iterator = CraftingManager.getInstance().getRecipeList().iterator();
        iterator.hasNext();
        hashset.add(Integer.valueOf(irecipe.func_25077_b().itemID))) {
      irecipe = (IRecipe) iterator.next();
    }

    ItemStack itemstack;
    for (Iterator iterator1 = FurnaceRecipes.smelting().getSmeltingList().values().iterator();
        iterator1.hasNext();
        hashset.add(Integer.valueOf(itemstack.itemID))) {
      itemstack = (ItemStack) iterator1.next();
    }

    field_25093_z = new StatBase[32000];
    Iterator iterator2 = hashset.iterator();
    do {
      if (!iterator2.hasNext()) {
        break;
      }
      Integer integer = (Integer) iterator2.next();
      if (Item.itemsList[integer.intValue()] != null) {
        String s =
            StatCollector.translateToLocalFormatted(
                "stat.craftItem", new Object[] {Item.itemsList[integer.intValue()].func_25006_i()});
        field_25093_z[integer.intValue()] =
            (new StatCrafting(0x1010000 + integer.intValue(), s, integer.intValue()))
                .func_27053_d();
      }
    } while (true);
    replaceAllSimilarBlocks(field_25093_z);
  }