use of minetweaker.api.item.IItemStack in project BetterStorage by copygirl.
the class MTCraftingStation method addShapeless.
@ZenMethod
public static void addShapeless(IItemStack[] output, IIngredient[] input, @Optional int experience, @Optional int craftingTime) {
ItemStack[] recipeOutput = MTHelper.toStacks(output);
IStationRecipe recipe = new MTShapelessStationRecipe(input, recipeOutput, experience, craftingTime);
MineTweakerAPI.apply(new UndoableRecipeAddAction(recipe, recipeOutput));
}
use of minetweaker.api.item.IItemStack in project BetterStorage by copygirl.
the class MTHelper method toStacks.
public static List<ItemStack> toStacks(List<IItemStack> mtStacks) {
List<ItemStack> stacks = new ArrayList<ItemStack>();
ItemStack stack;
for (IItemStack mtStack : mtStacks) if ((stack = toStack(mtStack)) != null)
stacks.add(stack);
return stacks;
}
use of minetweaker.api.item.IItemStack 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.IItemStack in project BetterStorage by copygirl.
the class MTCraftingStation method addShaped.
private static void addShaped(IItemStack[] output, IIngredient[][] input, int experience, int craftingTime, boolean mirrored) {
ItemStack[] recipeOutput = MTHelper.toStacks(output);
IStationRecipe recipe = new MTShapedStationRecipe(input, recipeOutput, experience, craftingTime, mirrored);
MineTweakerAPI.apply(new UndoableRecipeAddAction(recipe, recipeOutput));
}
use of minetweaker.api.item.IItemStack in project Minechem by iopleke.
the class InputHelper method getItem.
public static ItemStack getItem(IIngredient input) {
if (input == null) {
return null;
}
if (input instanceof IOreDictEntry) {
ItemStack result = OreDictionary.getOres(((IOreDictEntry) input).getName()).get(0).copy();
result.stackSize = input.getAmount();
if (MinechemUtil.itemStackToChemical(result) != null) {
return null;
}
return result;
} else if (input instanceof IngredientStack) {
ItemStack result = toStack(input.getItems().get(0));
result.stackSize = input.getAmount();
if (MinechemUtil.itemStackToChemical(result) != null) {
return null;
}
return result;
} else if (input instanceof IItemStack) {
if (MinechemUtil.itemStackToChemical(toStack((IItemStack) input)) != null) {
return null;
}
return toStack((IItemStack) input);
}
return null;
}
Aggregations