use of com.codetaylor.mc.artisanworktables.api.internal.recipe.IArtisanIngredient in project artisan-worktables by codetaylor.
the class RecipeBuilderCopyStrategyByOutput method apply.
@Override
public void apply(RecipeBuilderInternal recipeBuilder, List<RecipeBuilderInternal> resultList) throws RecipeBuilderException {
Collection<IRecipe> recipes = ForgeRegistries.RECIPES.getValuesCollection();
Set<IRecipe> toCopy = new HashSet<>();
for (IRecipe recipe : recipes) {
for (IArtisanIngredient copyRecipe : this.toCopy) {
if (!recipe.getRecipeOutput().isEmpty() && copyRecipe.matches(recipe.getRecipeOutput())) {
toCopy.add(recipe);
}
}
}
for (IRecipe recipe : toCopy) {
try {
this.doCopy(recipe, recipeBuilder.copy(), resultList);
} catch (Exception e) {
throw new RecipeBuilderException("Unable to copy recipe by output: " + recipe.getRegistryName(), e);
}
}
}
use of com.codetaylor.mc.artisanworktables.api.internal.recipe.IArtisanIngredient in project artisan-worktables by codetaylor.
the class SecondaryIngredientMatcher method matches.
@Override
public boolean matches(Collection<IArtisanIngredient> requiredIngredients) {
for (int i = 0; i < this.inputs.size(); i++) {
IArtisanItemStack iItemStack = this.inputs.get(i);
this.availableAmounts[i] = (iItemStack != null) ? iItemStack.getAmount() : 0;
}
for (IArtisanIngredient recipeInput : requiredIngredients) {
int amountRequired = recipeInput.getAmount();
for (int i = 0; i < this.inputs.size(); i++) {
IArtisanItemStack input = this.inputs.get(i);
if (input == null) {
continue;
}
if (recipeInput.matchesIgnoreAmount(input)) {
if (this.availableAmounts[i] >= amountRequired) {
// more ingredients are available in this stack than are required
// adjust and break
this.availableAmounts[i] -= amountRequired;
amountRequired = 0;
break;
} else {
// there aren't enough ingredients available to satisfy the entire requirement
// adjust and keep looking
amountRequired -= this.availableAmounts[i];
this.availableAmounts[i] = 0;
}
}
}
if (amountRequired > 0) {
// the requirements were not met
return false;
}
}
return true;
}
use of com.codetaylor.mc.artisanworktables.api.internal.recipe.IArtisanIngredient in project artisan-worktables by codetaylor.
the class JEIRecipeWrapper method getInputs.
public List<List<ItemStack>> getInputs() {
List<List<ItemStack>> result = new ArrayList<>();
for (IArtisanIngredient input : this.artisanRecipe.getIngredientList()) {
ItemStack[] matchingStacks = input.toIngredient().getMatchingStacks();
List<ItemStack> list = new ArrayList<>(matchingStacks.length);
for (ItemStack matchingStack : matchingStacks) {
list.add(matchingStack.copy());
}
result.add(list);
}
return result;
}
use of com.codetaylor.mc.artisanworktables.api.internal.recipe.IArtisanIngredient in project artisan-worktables by codetaylor.
the class JEIRecipeWrapper method getSecondaryInputs.
public List<List<ItemStack>> getSecondaryInputs() {
List<List<ItemStack>> result = new ArrayList<>();
for (IArtisanIngredient ingredient : this.artisanRecipe.getSecondaryIngredients()) {
ItemStack[] matchingStacks = ingredient.toIngredient().getMatchingStacks();
List<ItemStack> list = new ArrayList<>(matchingStacks.length);
for (ItemStack matchingStack : matchingStacks) {
list.add(matchingStack.copy());
}
result.add(list);
}
return result;
}
Aggregations