Search in sources :

Example 31 with PotionChemical

use of minechem.potion.PotionChemical in project Minechem by iopleke.

the class SynthesisRecipeHandler method itemStacksMatchesShapelessRecipe.

private boolean itemStacksMatchesShapelessRecipe(ItemStack[] stacks, SynthesisRecipe recipe, int factor) {
    ArrayList<ItemStack> stacksList = new ArrayList<ItemStack>();
    ArrayList<ItemStack> shapelessRecipe = MinechemUtil.convertChemicalsIntoItemStacks(new ArrayList<PotionChemical>(Arrays.asList(recipe.getShapelessRecipe())));
    for (ItemStack itemstack : stacks) {
        if (itemstack != null) {
            stacksList.add(itemstack.copy());
        }
    }
    for (ItemStack itemstack : stacksList) {
        int ingredientSlot = getIngredientSlotThatMatchesStack(shapelessRecipe, itemstack, 1);
        if (ingredientSlot != -1) {
            shapelessRecipe.remove(ingredientSlot);
        } else {
            return false;
        }
    }
    return shapelessRecipe.size() == 0;
}
Also used : ArrayList(java.util.ArrayList) PotionChemical(minechem.potion.PotionChemical) ItemStack(net.minecraft.item.ItemStack)

Aggregations

PotionChemical (minechem.potion.PotionChemical)31 ItemStack (net.minecraft.item.ItemStack)13 ArrayList (java.util.ArrayList)9 Molecule (minechem.item.molecule.Molecule)8 Element (minechem.item.element.Element)7 DecomposerRecipe (minechem.tileentity.decomposer.DecomposerRecipe)7 MoleculeEnum (minechem.item.molecule.MoleculeEnum)4 SynthesisRecipe (minechem.tileentity.synthesis.SynthesisRecipe)4 MapKey (minechem.utils.MapKey)4 ZenMethod (stanhebben.zenscript.annotations.ZenMethod)4 ElementItem (minechem.item.element.ElementItem)3 Item (net.minecraft.item.Item)3 HashMap (java.util.HashMap)2 MinechemBucketItem (minechem.item.bucket.MinechemBucketItem)2 ElementEnum (minechem.item.element.ElementEnum)2 MoleculeItem (minechem.item.molecule.MoleculeItem)2 DecomposerRecipeChance (minechem.tileentity.decomposer.DecomposerRecipeChance)2 DecomposerRecipeSelect (minechem.tileentity.decomposer.DecomposerRecipeSelect)2 IIngredient (minetweaker.api.item.IIngredient)2 ILuaContext (dan200.computercraft.api.lua.ILuaContext)1