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;
  }
Beispiel #2
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;
  }