Search in sources :

Example 11 with PotionChemical

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

the class RadiationMoleculeHandler method toItemStacks.

private ItemStack[] toItemStacks(PotionChemical[] chemicalsArray) {
    List<ItemStack> itemStacks = new ArrayList<ItemStack>();
    List<PotionChemical> chemicals = new ArrayList<PotionChemical>(chemicalsArray.length);
    for (int i = 0; i < chemicalsArray.length; i++) {
        chemicals.add(chemicalsArray[i]);
    }
    while (!chemicals.isEmpty()) {
        int index = chemicals.size() - 1;
        PotionChemical chemical = chemicals.remove(index);
        Item thisType;
        int thisDamage;
        if (chemical instanceof Element) {
            thisType = MinechemItemsRegistration.element;
            thisDamage = ((Element) chemical).element.atomicNumber();
        } else if (chemical instanceof Molecule) {
            thisType = MinechemItemsRegistration.molecule;
            thisDamage = ((Molecule) chemical).molecule.id();
        } else {
            continue;
        }
        for (int l = 0; l < itemStacks.size(); l++) {
            if (chemical.amount <= 0) {
                break;
            }
            ItemStack stack = itemStacks.get(l);
            if (stack.getItem() == thisType && stack.getItemDamage() == thisDamage) {
                int freeSpace = 64 - stack.stackSize;
                int append = freeSpace > chemical.amount ? chemical.amount : freeSpace;
                chemical.amount -= append;
                stack.stackSize += append;
            }
        }
        if (chemical.amount > 0) {
            itemStacks.add(new ItemStack(thisType, chemical.amount, thisDamage));
        }
    }
    return itemStacks.toArray(new ItemStack[itemStacks.size()]);
}
Also used : MinechemBucketItem(minechem.item.bucket.MinechemBucketItem) Item(net.minecraft.item.Item) ElementItem(minechem.item.element.ElementItem) MoleculeItem(minechem.item.molecule.MoleculeItem) Molecule(minechem.item.molecule.Molecule) Element(minechem.item.element.Element) PotionChemical(minechem.potion.PotionChemical) ItemStack(net.minecraft.item.ItemStack)

Example 12 with PotionChemical

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

the class Synthesiser method addRecipe.

@ZenMethod
public static void addRecipe(IIngredient[] inputs, IIngredient outputStack, boolean shaped, int energy) {
    boolean someValue = false;
    PotionChemical[] inputFixed = new PotionChemical[9];
    if (shaped) {
        for (int i = 0; i < inputFixed.length && i < inputs.length; i++) {
            if (inputs[i] != null) {
                inputFixed[i] = InputHelper.getChemical(inputs[i]);
                if (inputFixed[i] != null)
                    someValue = true;
            }
        }
    } else {
        List<PotionChemical> input = InputHelper.getChemicals(inputs);
        inputFixed = Arrays.copyOf(input.toArray(new PotionChemical[0]), 9);
        someValue = !input.isEmpty();
    }
    if (someValue) {
        ItemStack output = InputHelper.getInput(outputStack);
        if (output != null) {
            MineTweakerAPI.apply(new AddRecipeAction(output, shaped, energy, inputFixed));
        }
    }
}
Also used : PotionChemical(minechem.potion.PotionChemical) ItemStack(net.minecraft.item.ItemStack) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Example 13 with PotionChemical

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

the class OreDictionaryDefaultHandler method scaleFloor.

private PotionChemical[] scaleFloor(PotionChemical[] composition, double factor) {
    ArrayList<PotionChemical> newComposition = new ArrayList<PotionChemical>();
    for (PotionChemical chem : composition) {
        PotionChemical newChem = chem.copy();
        newChem.amount = (int) Math.floor(chem.amount * factor);
        if (newChem.amount > 0) {
            newComposition.add(newChem);
        }
    }
    return newComposition.toArray(new PotionChemical[newComposition.size()]);
}
Also used : ArrayList(java.util.ArrayList) PotionChemical(minechem.potion.PotionChemical)

Example 14 with PotionChemical

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

the class MoleculeEnum method registerMTMolecule.

public static void registerMTMolecule(MoleculeEnum molecule) {
    addMapping(molecule);
    ArrayList<PotionChemical> var5 = molecule.components();
    PotionChemical[] var6 = var5.toArray(new PotionChemical[var5.size()]);
    ItemStack var7 = new ItemStack(MinechemItemsRegistration.molecule, 1, molecule.id());
    DecomposerRecipe.add(new DecomposerRecipe(var7, var6));
    SynthesisRecipe.add(new SynthesisRecipe(var7, true, MinechemRecipes.COST_ITEM, var6));
}
Also used : SynthesisRecipe(minechem.tileentity.synthesis.SynthesisRecipe) PotionChemical(minechem.potion.PotionChemical) DecomposerRecipe(minechem.tileentity.decomposer.DecomposerRecipe) ItemStack(net.minecraft.item.ItemStack)

Example 15 with PotionChemical

use of minechem.potion.PotionChemical 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)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