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()]);
}
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));
}
}
}
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()]);
}
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));
}
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);
}
}
Aggregations