use of com.codetaylor.mc.artisanworktables.api.internal.recipe.IArtisanItemStack in project artisan-worktables by codetaylor.
the class TileEntitySecondaryInputBase method getSecondaryIngredientMatcher.
@Override
public ISecondaryIngredientMatcher getSecondaryIngredientMatcher() {
int slotCount = this.secondaryIngredientHandler.getSlots();
List<IArtisanItemStack> inputs = new ArrayList<>(slotCount);
for (int i = 0; i < slotCount; i++) {
ItemStack itemStack = this.secondaryIngredientHandler.getStackInSlot(i);
inputs.add(ArtisanItemStack.from(itemStack));
}
return new SecondaryIngredientMatcher(inputs);
}
use of com.codetaylor.mc.artisanworktables.api.internal.recipe.IArtisanItemStack 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.IArtisanItemStack in project artisan-worktables by codetaylor.
the class RecipeBuilderCopyHelper method replaceRecipeOutput.
public static IRecipeBuilder replaceRecipeOutput(IRecipe recipe, IArtisanItemStack toReplace, IRecipeBuilder builder) throws RecipeBuilderException {
ItemStack itemStack = toReplace.toItemStack();
int count = recipe.getRecipeOutput().getCount();
itemStack.setCount(count);
builder.addOutput(ArtisanItemStack.from(itemStack), 1);
return builder;
}
Aggregations