Search in sources :

Example 1 with IIngredient

use of minetweaker.api.item.IIngredient in project Minechem by iopleke.

the class InputHelper method getChemical.

public static PotionChemical getChemical(IIngredient ingredient) {
    if (ingredient instanceof IngredientStack) {
        for (IIngredient in : ingredient.getItems()) {
            if (in instanceof IItemStack) {
                ItemStack result = toStack((IItemStack) in);
                result.stackSize = Math.max(1, ingredient.getAmount());
                PotionChemical chemical = MinechemUtil.itemStackToChemical(result);
                if (chemical != null) {
                    return chemical;
                }
            }
        }
        return null;
    } else if (ingredient instanceof IOreDictEntry) {
        ArrayList<ItemStack> results = (ArrayList<ItemStack>) OreDictionary.getOres(((IOreDictEntry) ingredient).getName()).clone();
        for (ItemStack res : results) {
            ItemStack result = res.copy();
            result.stackSize = ingredient.getAmount();
            PotionChemical chemical = MinechemUtil.itemStackToChemical(result);
            if (chemical != null) {
                return chemical;
            }
        }
    } else if (ingredient instanceof IItemStack) {
        return MinechemUtil.itemStackToChemical(toStack((IItemStack) ingredient));
    }
    return null;
}
Also used : IIngredient(minetweaker.api.item.IIngredient) IItemStack(minetweaker.api.item.IItemStack) IOreDictEntry(minetweaker.api.oredict.IOreDictEntry) ArrayList(java.util.ArrayList) PotionChemical(minechem.potion.PotionChemical) IngredientStack(minetweaker.api.item.IngredientStack) IItemStack(minetweaker.api.item.IItemStack) ItemStack(net.minecraft.item.ItemStack)

Example 2 with IIngredient

use of minetweaker.api.item.IIngredient in project Minechem by iopleke.

the class Decomposer method addRecipe.

/**
 * Add Recipe
 *
 * @param input as input stack
 * @param chance	chance of output (Optional)
 * @param multiOutputs as Ingredient stack array
 */
@ZenMethod
public static void addRecipe(IIngredient input, @Optional double chance, IIngredient[]... multiOutputs) {
    if (multiOutputs.length == 1) {
        IIngredient[] outputs = multiOutputs[0];
        ArrayList<PotionChemical> output = InputHelper.getChemicals(outputs);
        if (output.size() == outputs.length) {
            ArrayList<ItemStack> toAdd = InputHelper.getInputs(input);
            for (ItemStack addInput : toAdd) {
                if (chance == 0 || chance >= 1) {
                    MineTweakerAPI.apply(new AddRecipeAction(addInput, output));
                } else if (chance < 1) {
                    MineTweakerAPI.apply(new AddRecipeAction(addInput, (float) chance, InputHelper.getArray(output)));
                }
            }
        } else {
            addSuperRecipe(input, outputs, output);
        }
    } else {
        addMultiRecipe(input, multiOutputs, chance);
    }
}
Also used : IIngredient(minetweaker.api.item.IIngredient) PotionChemical(minechem.potion.PotionChemical) ItemStack(net.minecraft.item.ItemStack) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Aggregations

PotionChemical (minechem.potion.PotionChemical)2 IIngredient (minetweaker.api.item.IIngredient)2 ItemStack (net.minecraft.item.ItemStack)2 ArrayList (java.util.ArrayList)1 IItemStack (minetweaker.api.item.IItemStack)1 IngredientStack (minetweaker.api.item.IngredientStack)1 IOreDictEntry (minetweaker.api.oredict.IOreDictEntry)1 ZenMethod (stanhebben.zenscript.annotations.ZenMethod)1