Search in sources :

Example 21 with PotionChemical

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

the class DecomposerRecipeSuper method getOutputRaw.

@Override
public ArrayList<PotionChemical> getOutputRaw() {
    ArrayList<PotionChemical> result = super.getOutputRaw();
    for (MapKey currentKey : this.recipes.keySet()) {
        DecomposerRecipe current = DecomposerRecipe.get(currentKey);
        LogHelper.debug("getOutputRaw: " + currentKey);
        if (current != null) {
            for (int i = 0; i < this.recipes.get(currentKey); i++) {
                ArrayList<PotionChemical> partialResult = current.getOutputRaw();
                partialResult = MinechemUtil.pushTogetherChemicals(partialResult);
                if (partialResult != null) {
                    result.addAll(partialResult);
                }
            }
        }
    }
    return MinechemUtil.pushTogetherChemicals(result);
}
Also used : MapKey(minechem.utils.MapKey) PotionChemical(minechem.potion.PotionChemical)

Example 22 with PotionChemical

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

the class DecomposerTileEntity method decomposeActiveStack.

/**
 * One of the most important functions in Minechem is the ability to decompose items into base molecules.
 */
private void decomposeActiveStack() {
    try {
        ItemStack inputStack = getActiveStack();
        DecomposerRecipe recipe;
        if (inputStack == cheatTankStack) {
            recipe = DecomposerRecipe.get(tank);
        } else {
            recipe = DecomposerRecipe.get(inputStack);
        }
        if (recipe != null && this.useEnergy(getEnergyNeeded())) {
            ArrayList<PotionChemical> output = recipe.getOutput();
            if (output != null) {
                ArrayList<ItemStack> stacks = MinechemUtil.convertChemicalsIntoItemStacks(getBrokenOutput(output, getDecompositionMultiplier(inputStack)));
                placeStacksInBuffer(stacks);
            }
        }
    } catch (Exception e) {
    // softly falls the rain
    // but the forest does not see
    // silently this fails
    }
}
Also used : PotionChemical(minechem.potion.PotionChemical) ItemStack(net.minecraft.item.ItemStack)

Example 23 with PotionChemical

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

the class RadiationMoleculeHandler method handleRadiationMoleculeBucket.

public RadiationInfo handleRadiationMoleculeBucket(World world, ItemStack itemStack, IInventory inventory, double x, double y, double z) {
    PotionChemical[] decayedChemicals = getDecayedMolecule((MoleculeEnum) ((MinechemBucketItem) itemStack.getItem()).chemical);
    for (int i = 0; i < decayedChemicals.length; i++) {
        decayedChemicals[i].amount *= 8 * itemStack.stackSize;
    }
    ItemStack[] items = toItemStacks(decayedChemicals);
    for (int i = 1; i < items.length; i++) {
        ItemStack stack = MinechemUtil.addItemToInventory(inventory, items[i]);
        if (stack != null) {
            MinechemUtil.throwItemStack(world, itemStack, x, y, z);
        }
    }
    Item item = items[0].getItem();
    if (item instanceof MoleculeItem) {
        itemStack.func_150996_a(MinechemBucketHandler.getInstance().buckets.get(FluidHelper.moleculeBlocks.get(FluidHelper.molecules.get(MoleculeItem.getMolecule(items[0])))));
    } else if (item instanceof ElementItem) {
        itemStack.func_150996_a(MinechemBucketHandler.getInstance().buckets.get(FluidHelper.elementsBlocks.get(FluidHelper.elements.get(ElementItem.getElement(items[0])))));
    }
    itemStack.stackSize = (items[0].stackSize / 8);
    itemStack.setTagCompound(items[0].stackTagCompound);
    return ElementItem.initiateRadioactivity(itemStack, world);
}
Also used : ElementItem(minechem.item.element.ElementItem) MinechemBucketItem(minechem.item.bucket.MinechemBucketItem) Item(net.minecraft.item.Item) ElementItem(minechem.item.element.ElementItem) MoleculeItem(minechem.item.molecule.MoleculeItem) MoleculeItem(minechem.item.molecule.MoleculeItem) MinechemBucketItem(minechem.item.bucket.MinechemBucketItem) PotionChemical(minechem.potion.PotionChemical) ItemStack(net.minecraft.item.ItemStack)

Example 24 with PotionChemical

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

the class RadiationMoleculeHandler method computDecayMolecule.

private Set<PotionChemical> computDecayMolecule(MoleculeEnum molecule) {
    List<PotionChemical> chemicals = molecule.components();
    Set<PotionChemical> outChemicals = new HashSet<PotionChemical>();
    if (molecule.radioactivity() == RadiationEnum.stable) {
        outChemicals.add(new Molecule(molecule));
        return outChemicals;
    }
    for (PotionChemical chemical1 : chemicals) {
        PotionChemical chemical = chemical1.copy();
        if (chemical instanceof Element) {
            Element element = (Element) chemical;
            if (element.element.radioactivity() != RadiationEnum.stable) {
                element.element = ElementEnum.getByID(element.element.atomicNumber() - 1);
            }
        } else if (chemical instanceof Molecule) {
            Molecule molecule2 = (Molecule) chemical;
            if (molecule2.molecule.radioactivity() != RadiationEnum.stable) {
                PotionChemical[] chemicals2 = getDecayedMolecule(molecule2.molecule);
                Collections.addAll(outChemicals, chemicals2);
                chemical = null;
            }
        }
        if (chemical != null) {
            outChemicals.add(chemical);
        }
    }
    return outChemicals;
}
Also used : Molecule(minechem.item.molecule.Molecule) Element(minechem.item.element.Element) PotionChemical(minechem.potion.PotionChemical)

Example 25 with PotionChemical

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

the class OreDictionaryDefaultHandler method scaleCeil.

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

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