use of minetweaker.api.item.IIngredient 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 minetweaker.api.item.IIngredient 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