Skip to content

Commit

Permalink
made a declaration more obvious and with more detailed explanation
Browse files Browse the repository at this point in the history
match formatting to the project.
  • Loading branch information
PrototypeTrousers committed Mar 31, 2021
1 parent 672083a commit 4110de6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void update() {
updateRecipeProgress();
}
//check everything that would make a recipe never start here.
if (progressTime == 0 && shouldSearchForRecipes()){
if (progressTime == 0 && shouldSearchForRecipes()) {
trySearchNewRecipe();
}
}
Expand All @@ -127,14 +127,19 @@ protected boolean shouldSearchForRecipes() {
protected boolean canFitNewOutputs() {
// if the output is full check if the output changed so we can process recipes results again.
if (this.isOutputsFull && !metaTileEntity.isOutputsDirty()) return false;
else { this.isOutputsFull = false; metaTileEntity.setOutputsDirty(false); }
else {
this.isOutputsFull = false;
metaTileEntity.setOutputsDirty(false);
}
return true;
}

protected boolean canWorkWithInputs() {
// if the inputs were bad last time, check if they've changed before trying to find a new recipe.
if (this.invalidInputsForRecipes && !metaTileEntity.isInputsDirty()) return false;
else { this.invalidInputsForRecipes = false; }
else {
this.invalidInputsForRecipes = false;
}
return true;
}

Expand Down Expand Up @@ -175,11 +180,14 @@ protected void trySearchNewRecipe() {
currentRecipe = findRecipe(maxVoltage, importInventory, importFluids);
}
// If a recipe was found, then inputs were valid.
// recipe multiplying machines may not be able to fit
// the multiplied recipes. in that case the inputs are valid
if (!(this.invalidInputsForRecipes = (currentRecipe == null && !this.isOutputsFull)))
// replace old recipe with new one
if (currentRecipe != null) {
this.invalidInputsForRecipes = false;
this.previousRecipe = currentRecipe;
// Add-ons may Override findRecipe method but not trySearchNewRecipe, in that case
// they may return a null recipe. Since we only check for items and fluid here, having
// findRecipe return a null recipe with isOutputsFull being true, means we have a valid
// recipe in the input waiting for space in the output.
} else this.invalidInputsForRecipes = !this.isOutputsFull;

// proceed if we have a usable recipe.
if (currentRecipe != null && setupAndConsumeRecipeInputs(currentRecipe)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected void onContentsChanged() {
}

@Override
public HashSet<MetaTileEntity> getNotifiableMetaTileEntities(){
public HashSet<MetaTileEntity> getNotifiableMetaTileEntities() {
return this.entitiesToNotify;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected void trySearchNewRecipe() {
//if previous recipe still matches inputs, try to use it
currentRecipe = previousRecipe;
}
if ( currentRecipe != null)
if (currentRecipe != null)
// replace old recipe with new one
this.previousRecipe = currentRecipe;

Expand Down Expand Up @@ -199,7 +199,7 @@ protected Recipe findRecipe(long maxVoltage,

// If there were no accepted ingredients, then there is no recipe to process.
// the output may be filled up
if(recipeInputs.isEmpty() && !invalidInputsForRecipes) {
if (recipeInputs.isEmpty() && !invalidInputsForRecipes) {
//Set here to prevent recipe deadlock on world load with full output bus
this.isOutputsFull = true;
return null;
Expand Down

0 comments on commit 4110de6

Please sign in to comment.