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