Search in sources :

Example 6 with PotionChemical

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

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

the class DecomposerRecipe method getPartialOutputRaw.

public ArrayList<PotionChemical> getPartialOutputRaw(int f) {
    ArrayList<PotionChemical> raw = getOutput();
    ArrayList<PotionChemical> result = new ArrayList<PotionChemical>();
    if (raw != null) {
        for (PotionChemical chem : raw) {
            try {
                if (chem != null) {
                    PotionChemical reduced = chem.copy();
                    if (reduced != null) {
                        reduced.amount = (int) Math.floor(chem.amount / f);
                        if (reduced.amount == 0 && rand.nextFloat() > (chem.amount / f)) {
                            reduced.amount = 1;
                        }
                        result.add(reduced);
                    }
                }
            } catch (Exception e) {
            // something has gone wrong
            // but we do not know quite why
            // debug code goes here
            }
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) PotionChemical(minechem.potion.PotionChemical)

Example 8 with PotionChemical

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

the class DecomposerRecipe method addChemicals.

public void addChemicals(PotionChemical... chemicals) {
    for (PotionChemical potionChemical : chemicals) {
        PotionChemical current = this.output.get(new MapKey(potionChemical));
        if (current != null) {
            current.amount += potionChemical.amount;
            continue;
        }
        this.output.put(new MapKey(potionChemical), potionChemical.copy());
    }
}
Also used : MapKey(minechem.utils.MapKey) PotionChemical(minechem.potion.PotionChemical)

Example 9 with PotionChemical

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

the class DecomposerTileEntity method getBrokenOutput.

private ArrayList<PotionChemical> getBrokenOutput(ArrayList<PotionChemical> output, double mult) {
    if (mult == 1) {
        return output;
    }
    if (mult <= 0) {
        return new ArrayList<PotionChemical>();
    }
    ArrayList<PotionChemical> result = new ArrayList<PotionChemical>();
    for (PotionChemical chemical : output) {
        PotionChemical addChemical = chemical.copy();
        addChemical.amount *= mult;
        result.add(addChemical);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) PotionChemical(minechem.potion.PotionChemical)

Example 10 with PotionChemical

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

the class RadiationMoleculeHandler method handleRadiationMolecule.

public RadiationInfo handleRadiationMolecule(World world, ItemStack itemStack, IInventory inventory, double x, double y, double z) {
    PotionChemical[] decayedChemicals = getDecayedMolecule(MoleculeItem.getMolecule(itemStack));
    for (int i = 0; i < decayedChemicals.length; i++) {
        decayedChemicals[i].amount *= 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);
        }
    }
    itemStack.setItemDamage(items[0].getItemDamage());
    itemStack.func_150996_a(items[0].getItem());
    itemStack.stackSize = (items[0].stackSize);
    itemStack.setTagCompound(items[0].stackTagCompound);
    return ElementItem.initiateRadioactivity(itemStack, world);
}
Also used : 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