From 4110de643dab359720980c3456e356ebf2b12c59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Salom=C3=A3o?= Date: Wed, 31 Mar 2021 15:23:10 -0300 Subject: [PATCH] made a declaration more obvious and with more detailed explanation match formatting to the project. --- .../capability/impl/AbstractRecipeLogic.java | 22 +++++++++++++------ .../capability/impl/NotifiableFluidTank.java | 2 +- .../electric/MetaTileEntityMultiFurnace.java | 4 ++-- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/main/java/gregtech/api/capability/impl/AbstractRecipeLogic.java b/src/main/java/gregtech/api/capability/impl/AbstractRecipeLogic.java index 6032e83121..e5f38b8013 100644 --- a/src/main/java/gregtech/api/capability/impl/AbstractRecipeLogic.java +++ b/src/main/java/gregtech/api/capability/impl/AbstractRecipeLogic.java @@ -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(); } } @@ -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; } @@ -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)) { diff --git a/src/main/java/gregtech/api/capability/impl/NotifiableFluidTank.java b/src/main/java/gregtech/api/capability/impl/NotifiableFluidTank.java index 4a9adc17dc..f62b41b240 100644 --- a/src/main/java/gregtech/api/capability/impl/NotifiableFluidTank.java +++ b/src/main/java/gregtech/api/capability/impl/NotifiableFluidTank.java @@ -24,7 +24,7 @@ protected void onContentsChanged() { } @Override - public HashSet getNotifiableMetaTileEntities(){ + public HashSet getNotifiableMetaTileEntities() { return this.entitiesToNotify; } } diff --git a/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityMultiFurnace.java b/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityMultiFurnace.java index 50242293fa..142402421b 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityMultiFurnace.java +++ b/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityMultiFurnace.java @@ -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; @@ -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;