Skip to content

Commit

Permalink
check ingredient amount
Browse files Browse the repository at this point in the history
  • Loading branch information
brachy84 committed Aug 3, 2023
1 parent 71d0947 commit 2dc6520
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ public class RecipeBuilder extends AbstractRecipeBuilder<ICompressorRecipe> {
@Override
public AbstractRecipeBuilder<ICompressorRecipe> input(IIngredient ingredient) {
if (ingredient == null) return this;
this.inputCount = ingredient.getAmount();
if (ingredient.getAmount() > 1) {
this.inputCount = ingredient.getAmount();
}
return super.input(ingredient.withAmount(1));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,18 @@ public RecipeBuilder recipeBuilder() {

public static class RecipeBuilder extends AbstractRecipeBuilder<CompressorRecipe> {

private IIngredient input;
private int inputCount;
private IIngredient catalyst = IngredientHelper.toIIngredient(ItemSingularity.getCatalystStack());
private boolean consumeCatalyst = false;
private int powerCost;
private int powerRate = ModConfig.confCompressorRFRate;

public RecipeBuilder input(IIngredient input) {
this.input = input.withAmount(1);
this.inputCount = input.getAmount();
if (input == null) return this;
if (input.getAmount() > 1) {
this.inputCount = input.getAmount();
}
this.input.add(input.withAmount(1));
return this;
}

Expand Down Expand Up @@ -140,10 +142,9 @@ public String getErrorMsg() {

@Override
public void validate(GroovyLog.Msg msg) {
validateItems(msg, 1, 1, 1, 1);
validateFluids(msg);

msg.add(IngredientHelper.isEmpty(input), () -> "input must not be empty");
msg.add(output.size() != 1, () -> getRequiredString(1, 1, "item output") + ", but found " + output.size());
msg.add(IngredientHelper.isEmpty(catalyst), "catalyst must not be empty");
msg.add(powerCost < 0, "power cost must not be negative");
msg.add(powerRate < 0, "power rate must not be negative");
Expand All @@ -153,7 +154,7 @@ public void validate(GroovyLog.Msg msg) {
@Override
public CompressorRecipe register() {
if (!validate()) return null;
CompressorRecipe recipe = new CompressorRecipe(output.get(0), input.toMcIngredient(), inputCount, catalyst.toMcIngredient(), consumeCatalyst, powerCost, powerRate);
CompressorRecipe recipe = new CompressorRecipe(output.get(0), input.get(0).toMcIngredient(), inputCount, catalyst.toMcIngredient(), consumeCatalyst, powerCost, powerRate);
ModSupport.EXTENDED_CRAFTING.get().compressionCrafting.add(recipe);
return recipe;
}
Expand Down

0 comments on commit 2dc6520

Please sign in to comment.