Search in sources :

Example 16 with PotionChemical

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

the class DecomposerNEIRecipeHandler method loadCraftingRecipes.

@Override
public void loadCraftingRecipes(ItemStack result) {
    // can yield it.
    if (!Compare.isStackAChemical(result)) {
        return;
    }
    // Add all decomposer recipes that can yield the result.
    PotionChemical resultChemical = MinechemUtil.itemStackToChemical(result);
    if (resultChemical == null) {
        return;
    }
    for (DecomposerRecipe dr : DecomposerRecipe.recipes.values()) {
        if (dr.outputContains(resultChemical)) {
            registerDecomposerRecipe(dr);
        }
    }
    arecipes = sortList(arecipes);
}
Also used : PotionChemical(minechem.potion.PotionChemical) DecomposerRecipe(minechem.tileentity.decomposer.DecomposerRecipe)

Example 17 with PotionChemical

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

the class Chemicals method removeMoleculeEffects.

@ZenMethod
public static void removeMoleculeEffects(IIngredient ingredient) {
    PotionChemical chemical = InputHelper.getChemical(ingredient);
    if (!(chemical instanceof Molecule)) {
        throw new IllegalArgumentException("Ingredient is not a molecule");
    }
    MineTweakerAPI.apply(new RemoveEffectsAction(((Molecule) chemical).molecule));
}
Also used : Molecule(minechem.item.molecule.Molecule) PotionChemical(minechem.potion.PotionChemical) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Example 18 with PotionChemical

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

the class Chemicals method addMolecule.

@ZenMethod
public static void addMolecule(String name, int id, String roomState, IIngredient[] chemicals) {
    ChemicalRoomStateEnum state = InputHelper.getRoomState(roomState);
    if (MoleculeEnum.getByName(name) != null || MoleculeEnum.getById(id) != null) {
        throw new IllegalArgumentException(name + " is already registered as a molecule");
    }
    ArrayList<PotionChemical> chem = InputHelper.getChemicals(chemicals);
    PotionChemical[] chemical = chem.toArray(new PotionChemical[chem.size()]);
    MineTweakerAPI.apply(new AddMoleculeAction(name, id, state, chemical));
}
Also used : PotionChemical(minechem.potion.PotionChemical) ChemicalRoomStateEnum(minechem.item.ChemicalRoomStateEnum) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Example 19 with PotionChemical

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

the class Chemicals method addEffect.

private static void addEffect(IIngredient ingredient, PharmacologyEffect effect) {
    PotionChemical chemical = InputHelper.getChemical(ingredient);
    if (!(chemical instanceof Molecule)) {
        throw new IllegalArgumentException("Ingredient is not a molecule");
    }
    MineTweakerAPI.apply(new AddMoleculeEffectAction(((Molecule) chemical).molecule, effect));
}
Also used : Molecule(minechem.item.molecule.Molecule) PotionChemical(minechem.potion.PotionChemical)

Example 20 with PotionChemical

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

the class DecomposerRecipeSuper method getOutput.

@Override
public ArrayList<PotionChemical> getOutput() {
    ArrayList<PotionChemical> result = super.getOutput();
    for (MapKey currentKey : this.recipes.keySet()) {
        DecomposerRecipe current = DecomposerRecipe.get(currentKey);
        if (current != null) {
            Double i = this.recipes.get(currentKey);
            LogHelper.debug("getOutput :" + currentKey + " chance: " + i);
            while (i >= 1) {
                ArrayList<PotionChemical> partialResult = current.getOutput();
                if (partialResult != null && partialResult.size() > 0) {
                    result.addAll(partialResult);
                }
                i--;
            }
            if (random.nextDouble() < i) {
                ArrayList<PotionChemical> partialResult = current.getOutput();
                if (partialResult != null) {
                    result.addAll(partialResult);
                }
            }
        }
    }
    return result;
}
Also used : MapKey(minechem.utils.MapKey) 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