Skip to content

Commit c847713

Browse files
make the if statements more readable
1 parent dfd6617 commit c847713

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

src/main/java/gregtech/api/capability/impl/AbstractRecipeLogic.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,11 @@ protected void trySearchNewRecipe() {
195195
else {
196196
currentRecipe = findRecipe(maxVoltage, importInventory, importFluids);
197197
}
198-
// If a recipe was found, then inputs were valid.
198+
// If a recipe was found, then inputs were valid. Cache found recipe.
199199
if (currentRecipe != null) {
200-
this.invalidInputsForRecipes = false;
201200
this.previousRecipe = currentRecipe;
202-
// Add-ons may Override findRecipe method but not trySearchNewRecipe, in that case
203-
// they may return a null recipe. Since we only check for items and fluid here, having
204-
// findRecipe return a null recipe with isOutputsFull being true, means we have a valid
205-
// recipe in the input waiting for space in the output.
206-
} else this.invalidInputsForRecipes = !this.isOutputsFull;
201+
}
202+
this.invalidInputsForRecipes = (currentRecipe == null);
207203

208204
// proceed if we have a usable recipe.
209205
if (currentRecipe != null && setupAndConsumeRecipeInputs(currentRecipe))

src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityMultiFurnace.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ protected Recipe findRecipe(long maxVoltage,
142142
/* Iterate over the input items looking for more things to add until we run either out of input items
143143
* or we have exceeded the number of items permissible from the smelting bonus
144144
*/
145-
this.invalidInputsForRecipes = true;
145+
boolean matchedRecipe = false;
146+
boolean canFitOutputs = true;
147+
146148
for(int index = 0; index < inputs.getSlots() && currentItemsEngaged < maxItemsLimit; index++) {
147149

148150
// Skip this slot if it is empty.
@@ -157,7 +159,7 @@ protected Recipe findRecipe(long maxVoltage,
157159
CountableIngredient inputIngredient;
158160
if(matchingRecipe != null) {
159161
inputIngredient = matchingRecipe.getInputs().get(0);
160-
this.invalidInputsForRecipes = false;
162+
matchedRecipe = true;
161163
}
162164
else
163165
continue;
@@ -185,7 +187,7 @@ protected Recipe findRecipe(long maxVoltage,
185187
computeOutputItemStacks(temp, matchingRecipe.getOutputs().get(0), recipeMultiplier);
186188

187189
// determine if there is enough room in the output to fit all of this
188-
boolean canFitOutputs = InventoryUtils.simulateItemStackMerge(temp, this.getOutputInventory());
190+
canFitOutputs = InventoryUtils.simulateItemStackMerge(temp, this.getOutputInventory());
189191

190192
// if there isn't, we can't process this recipe.
191193
if(!canFitOutputs)
@@ -203,13 +205,10 @@ protected Recipe findRecipe(long maxVoltage,
203205
}
204206
}
205207

206-
// If there were no accepted ingredients, then there is no recipe to process.
207-
// the output may be filled up
208-
if (recipeInputs.isEmpty() && !invalidInputsForRecipes) {
209-
//Set here to prevent recipe deadlock on world load with full output bus
210-
this.isOutputsFull = true;
211-
return null;
212-
} else if (recipeInputs.isEmpty()) {
208+
this.invalidInputsForRecipes = !matchedRecipe;
209+
this.isOutputsFull = !canFitOutputs;
210+
211+
if (recipeInputs.isEmpty()) {
213212
return null;
214213
}
215214

0 commit comments

Comments
 (0)