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