diff options
| author | Maxim <maxim235@gmx.de> | 2023-07-10 10:13:04 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-10 10:13:04 +0200 |
| commit | fe0387946550f89a403b09f4e8cf6e43ee8f2e8f (patch) | |
| tree | 6b56a553c2a5bbf2427a93e92724452ba5bc60f7 /src/main/java/gregtech/common | |
| parent | 9fe44bf0eaa55825c1c3cdf90f69aeeb668f45b1 (diff) | |
| download | GT5-Unofficial-fe0387946550f89a403b09f4e8cf6e43ee8f2e8f.tar.gz GT5-Unofficial-fe0387946550f89a403b09f4e8cf6e43ee8f2e8f.tar.bz2 GT5-Unofficial-fe0387946550f89a403b09f4e8cf6e43ee8f2e8f.zip | |
Generic processing logic (#2096)
* Added enumeration for check recipe result
* Rework processing logic to work with MTEs too
* Switched first few multiblocks to new checkRecipe method
* Applied generic logic to EBF
* Added support for long power base and applied generic processing logic to more machines
* Address some feedback
* Added more setter to further configure the processing logic
* Change internal checkRecipe to work with checkRecipeResult, to allow the injection of custom failure messages
* Suppress warning, change access
* Merge recipeMap and mapSupplier
* Move calls to setMetaTEController and setRecipeMap to base classes
* Make processingLogic final
* Make results non-null
* Rename `ProcessingLogic#checkRecipe` -> `#validateRecipe`
Otherwise it's confusing with `GT_MetaTileEntity_MultiBlockBase#checkRecipe`
* oops
* Added recipe locking to generic processing logic
* Rename: getWorldObject -> getIHasWorldObjectAndCoords
* Annotate missing overrides
* Renamed recipeLockableController -> recipeLockableMachine
* Migrated Cleanroom
* Migrated pyrolyse oven
* Migrated driller
* Migrated charcoal pit
* Migrated DT
* Rename: controller -> machine
* Make recipemaps override base `findRecipe` and mark others final
* Remove unused maps
* Add FindRecipeResult
* Remove IHasWorldObjectAndCoords parameter from findRecipe
This removes argument for printer recipemap to pass for GT_ModHandler.getAllRecipeOutput, but I don't think there's any mod that adds world-specific coloring recipe.
* Added method to set processing logic power so machines can override it on demand
* Restructure CheckRecipeResult, show voltage required and move package
* Reword: insufficient voltage -> power
* Change text color: dark gray -> gray
* Added findRecipeResult for insufficient heat
* Migrated PCB factory
* Fix result not being reset on shut down
* Show coil tier for heat
* clean
* Reverted migration of driller base
* Migrated TPM
* Moved getting of parallel supplier, to accomodate TPM
* Migrated power gen multiblocks
* Migrated Assembling Line
* Migrated fusion
* Migrated multi smelter
* Migrated boiler
* Migrated DTPF
* Migrated ore factory
* Migrated heat exchanger
* Make checkRecipe() final, javadoc, minor cleanup
* Fix overclock behavior with multiple hatches, javadoc, minor cleanup
* Minor fix for javadoc
* Fixed creation of OC calculator not factoring in batch mode correctly
* Make GT_ParallelHelper#setRecipe nonnull
* Rework SimpleCheckRecipeResult to not require registration
* Migrate charcoal pit and cleanroom
* Fix result not being reset when turning off machine
* Add API for BW to make recipemap sensitive to special slot on recipe search
* Migrated PA
* Migrated driller base
* Make ProcessingLogic#duration int
* Minor cleanup
* missing recipe locking for long multi
* Fix NPE
* Show crash message and turn off machine
* minor javadoc fix
* Fixed power setting for extended power base
* Integrate SingleRecipeCheck into ProcessingLogic, fix duration overflow, fix duration for batch mode, migrate PA for GT_MetaTileEntity_ExtendedPowerMultiBlockBase
* Fixed ME stocking busses
* Minor PA fixes
* Cleanup item collecting logic & apply to normal multi as well
* Oversight
* Derp
* Multiple voltage instead of amperage with recipe map amperage, since usually amperage is intended for parallel, not for recipe checking
* Fix missing EU modifiers on PCB factory OC calculator
* Removed left over OC method
* Fixed duration calculation of PCB not applying roughness multiplier
* Fixed OC parameters
* Make createOverclockCalculator nonnull & more nonnull annotations
* Fixed input processing voltage
* Round down voltage for other machines too
* Revert Nano Forge, return correct long voltage
* Use region / endregion
---------
Co-authored-by: miozune <miozune@gmail.com>
Diffstat (limited to 'src/main/java/gregtech/common')
28 files changed, 624 insertions, 1133 deletions
diff --git a/src/main/java/gregtech/common/gui/modularui/widget/CheckRecipeResultSyncer.java b/src/main/java/gregtech/common/gui/modularui/widget/CheckRecipeResultSyncer.java new file mode 100644 index 0000000000..9028c66be8 --- /dev/null +++ b/src/main/java/gregtech/common/gui/modularui/widget/CheckRecipeResultSyncer.java @@ -0,0 +1,26 @@ +package gregtech.common.gui.modularui.widget; + +import java.util.function.Consumer; +import java.util.function.Supplier; + +import com.gtnewhorizons.modularui.common.internal.network.NetworkUtils; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; + +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; + +public class CheckRecipeResultSyncer extends FakeSyncWidget<CheckRecipeResult> { + + public CheckRecipeResultSyncer(Supplier<CheckRecipeResult> getter, Consumer<CheckRecipeResult> setter) { + super(getter, setter, (buffer, result) -> { + NetworkUtils.writeStringSafe(buffer, result.getID()); + result.encode(buffer); + }, buffer -> { + String id = NetworkUtils.readStringSafe(buffer); + CheckRecipeResult result = CheckRecipeResultRegistry.getSampleFromRegistry(id) + .newInstance(); + result.decode(buffer); + return result; + }); + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java index 454f04066f..5575b0f9f1 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java @@ -24,6 +24,8 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; @@ -32,7 +34,6 @@ import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; -import gregtech.api.enums.SoundResource; import gregtech.api.enums.Textures; import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.interfaces.IHatchElement; @@ -45,6 +46,8 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_DataA import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_MultiInput; import gregtech.api.multitileentity.multiblock.casing.Glasses; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_AssemblyLineUtils; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; @@ -185,13 +188,14 @@ public class GT_MetaTileEntity_AssemblyLine } @Override - public boolean checkRecipe(ItemStack aStack) { + @NotNull + public CheckRecipeResult checkProcessing() { if (GT_Values.D1) { GT_FML_LOGGER.info("Start ALine recipe check"); } ArrayList<ItemStack> tDataStickList = getDataItems(2); if (tDataStickList.isEmpty()) { - return false; + return CheckRecipeResultRegistry.NO_DATA_STICKS; } if (GT_Values.D1) { GT_FML_LOGGER.info("Stick accepted, " + tDataStickList.size() + " Data Sticks found"); @@ -305,7 +309,7 @@ public class GT_MetaTileEntity_AssemblyLine // Best not to run this recipe. if (!foundRecipe || tStack.length == 0) { - return false; + return CheckRecipeResultRegistry.NO_RECIPE; } if (GT_Values.D1) { @@ -340,7 +344,7 @@ public class GT_MetaTileEntity_AssemblyLine if (GT_Values.D1) { GT_FML_LOGGER.info("Recipe successful"); } - return true; + return CheckRecipeResultRegistry.SUCCESSFUL; } private static int isStackValidIngredient(ItemStack aSlotStack, ItemStack aIngredient, ItemStack[] alts) { @@ -367,14 +371,6 @@ public class GT_MetaTileEntity_AssemblyLine } @Override - public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 20) { - GT_Utility.doSoundAtClient(SoundResource.IC2_MACHINES_MAGNETIZER_LOOP, 10, 1.0F, aX, aY, aZ); - } - } - - @Override public IStructureDefinition<GT_MetaTileEntity_AssemblyLine> getStructureDefinition() { return STRUCTURE_DEFINITION; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Charcoal_Pit.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Charcoal_Pit.java index 6250b11300..392b77eb74 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Charcoal_Pit.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Charcoal_Pit.java @@ -9,6 +9,8 @@ import static gregtech.api.objects.XSTR.XSTR_INSTANCE; import java.util.ArrayList; +import javax.annotation.Nonnull; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; @@ -27,6 +29,8 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TooltipMultiBlockBase; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; @@ -62,14 +66,15 @@ public class GT_MetaTileEntity_Charcoal_Pit extends GT_MetaTileEntity_TooltipMul return true; } + @Nonnull @Override - public boolean checkRecipe(ItemStack aStack) { + public CheckRecipeResult checkProcessing() { if (!checkRecursiveBlocks()) { mEfficiency = 0; mEfficiencyIncrease = 0; mMaxProgresstime = 0; running = false; - return false; + return CheckRecipeResultRegistry.NO_RECIPE; } if (mEfficiency == 0) { @@ -79,13 +84,13 @@ public class GT_MetaTileEntity_Charcoal_Pit extends GT_MetaTileEntity_TooltipMul // adds all the pollution at once when the recipe starts GT_Pollution.addPollution(getBaseMetaTileEntity(), mMaxProgresstime * getPollutionPerTick(null)); - return true; + return CheckRecipeResultRegistry.SUCCESSFUL; } else { mEfficiency = 0; mEfficiencyIncrease = 0; mMaxProgresstime = 0; + return CheckRecipeResultRegistry.NO_RECIPE; } - return false; } private boolean checkRecursiveBlocks() { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java index 07023bfdcf..4c308370aa 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java @@ -12,6 +12,8 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import javax.annotation.Nonnull; + import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -33,6 +35,8 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicHull; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TooltipMultiBlockBase; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; @@ -116,15 +120,16 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_TooltipMultiB return new String[] { "The base can be rectangular." }; } + @Nonnull @Override - public boolean checkRecipe(ItemStack aStack) { + public CheckRecipeResult checkProcessing() { mEfficiencyIncrease = 100; // use the standard overclock mechanism to determine duration and estimate a maximum consumption calculateOverclockedNessMultiInternal(40, 45 * Math.max(1, mHeight - 1), 1, getMaxInputVoltage(), false); // negate it to trigger the special energy consumption function. divide by 10 to get the actual final // consumption. mEUt /= -10; - return true; + return SimpleCheckRecipeResult.ofSuccess("cleanroom_running"); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java index ff28a9e40a..ff8fa7eeb1 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java @@ -24,6 +24,8 @@ import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; @@ -38,6 +40,9 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; @@ -183,7 +188,8 @@ public class GT_MetaTileEntity_DieselEngine } @Override - public boolean checkRecipe(ItemStack aStack) { + @NotNull + public CheckRecipeResult checkProcessing() { ArrayList<FluidStack> tFluids = getStoredFluids(); // fast track lookup @@ -219,30 +225,30 @@ public class GT_MetaTileEntity_DieselEngine } // Deplete that amount - if (!depleteInput(tLiquid)) return false; + if (!depleteInput(tLiquid)) return CheckRecipeResultRegistry.NO_FUEL_FOUND; boostEu = depleteInput(getBooster().getGas(2L * getAdditiveFactor())); // Check to prevent burning HOG without consuming it, if not boosted if (!boostEu && fuelValue > getNominalOutput()) { - return false; + return SimpleCheckRecipeResult.ofFailure("fuel_quality_too_high"); } // Deplete Lubricant. 1000L should = 1 hour of runtime (if baseEU = 2048) if ((mRuntime % 72 == 0 || mRuntime == 0) && !depleteInput(Materials.Lubricant.getFluid((boostEu ? 2L : 1L) * getAdditiveFactor()))) - return false; + return SimpleCheckRecipeResult.ofFailure("no_lubricant"); fuelRemaining = tFluid.amount; // Record available fuel this.mEUt = mEfficiency < 2000 ? 0 : getNominalOutput(); // Output 0 if startup is less than 20% this.mProgresstime = 1; this.mMaxProgresstime = 1; this.mEfficiencyIncrease = getEfficiencyIncrease(); - return true; + return CheckRecipeResultRegistry.GENERATING; } } this.mEUt = 0; this.mEfficiency = 0; - return false; + return CheckRecipeResultRegistry.NO_FUEL_FOUND; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java index 3a75cab071..e368e43518 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java @@ -40,12 +40,12 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.fluid.IFluidStore; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_EnhancedMultiBlockBase<GT_MetaTileEntity_DistillationTower> implements ISurvivalConstructable { @@ -191,72 +191,8 @@ public class GT_MetaTileEntity_DistillationTower extends } @Override - public boolean checkRecipe(ItemStack aStack) { - GT_Recipe tRecipe; - - ArrayList<ItemStack> tInputList = getStoredInputs(); - int tInputList_sS = tInputList.size(); - for (int i = 0; i < tInputList_sS - 1; i++) { - for (int j = i + 1; j < tInputList_sS; j++) { - if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { - if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { - tInputList.remove(j--); - tInputList_sS = tInputList.size(); - } else { - tInputList.remove(i--); - tInputList_sS = tInputList.size(); - break; - } - } - } - } - ItemStack[] inputs = tInputList.toArray(new ItemStack[0]); - - ArrayList<FluidStack> tFluidList = getStoredFluids(); - for (int i = 0; i < tFluidList.size() - 1; i++) { - for (int j = i + 1; j < tFluidList.size(); j++) { - if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { - tFluidList.remove(j--); - } else { - tFluidList.remove(i--); - break; - } - } - } - } - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(0, GT_Utility.getTier(tVoltage)); - FluidStack[] tFluids = tFluidList.toArray(new FluidStack[0]); - for (FluidStack tFluid : tFluids) { - tRecipe = GT_Recipe.GT_Recipe_Map.sDistillationRecipes.findRecipe( - getBaseMetaTileEntity(), - false, - gregtech.api.enums.GT_Values.V[tTier], - new FluidStack[] { tFluid }, - inputs); - if (tRecipe != null) { - if (!canOutputAll(tRecipe)) continue; - if (tRecipe.isRecipeInputEqual(true, tFluids, inputs)) { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - calculateOverclockedNessMultiInternal(tRecipe.mEUt, tRecipe.mDuration, 1, tVoltage, false); - // In case recipe is too OP for that machine - if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) return false; - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[] { tRecipe.getOutput(0) }; - this.mOutputFluids = tRecipe.mFluidOutputs.clone(); - updateSlots(); - return true; - } - } - } - - return false; + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic(); } protected void onCasingFound() { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java index 8c671f69a8..77b5073c86 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java @@ -33,6 +33,8 @@ import net.minecraft.world.ChunkCoordIntPair; import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.ForgeDirection; +import org.jetbrains.annotations.NotNull; + import com.google.common.collect.ImmutableList; import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; @@ -53,6 +55,8 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_DataAccess; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; import gregtech.api.objects.GT_ChunkManager; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; @@ -414,21 +418,38 @@ public abstract class GT_MetaTileEntity_DrillerBase } @Override - public boolean checkRecipe(ItemStack aStack) { + @NotNull + public CheckRecipeResult checkProcessing() { + ItemStack controllerStack = getControllerSlot(); // Public pipe actions setElectricityStats(); int oldYHead = yHead; if (!checkPipesAndSetYHead() || !isEnergyEnough()) { stopMachine(); - return false; + return SimpleCheckRecipeResult.ofFailure("no_mining_pipe"); } putMiningPipesFromInputsInController(); - return switch (workState) { - case STATE_DOWNWARD -> workingDownward(aStack, xDrill, yDrill, zDrill, xPipe, zPipe, yHead, oldYHead); - case STATE_AT_BOTTOM -> workingAtBottom(aStack, xDrill, yDrill, zDrill, xPipe, zPipe, yHead, oldYHead); - case STATE_UPWARD -> workingUpward(aStack, xDrill, yDrill, zDrill, xPipe, zPipe, yHead, oldYHead); - default -> false; - }; + switch (workState) { + case STATE_DOWNWARD -> { + return workingDownward(controllerStack, xDrill, yDrill, zDrill, xPipe, zPipe, yHead, oldYHead) + ? SimpleCheckRecipeResult.ofSuccess("drilling") + : SimpleCheckRecipeResult.ofFailure("extracting_pipe"); + + } + case STATE_AT_BOTTOM -> { + return workingAtBottom(controllerStack, xDrill, yDrill, zDrill, xPipe, zPipe, yHead, oldYHead) + ? SimpleCheckRecipeResult.ofSuccess("drilling") + : SimpleCheckRecipeResult.ofFailure("no_mining_pipe"); + } + case STATE_UPWARD -> { + return workingUpward(controllerStack, xDrill, yDrill, zDrill, xPipe, zPipe, yHead, oldYHead) + ? SimpleCheckRecipeResult.ofSuccess("retracting_pipe") + : SimpleCheckRecipeResult.ofFailure("no_mining_pipe"); + } + default -> { + return SimpleCheckRecipeResult.ofFailure("no_mining_pipe"); + } + } } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java index 0557128b60..65890b0cc0 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java @@ -8,7 +8,6 @@ import static gregtech.api.enums.GT_HatchElement.Maintenance; import static gregtech.api.enums.GT_HatchElement.Muffler; import static gregtech.api.enums.GT_HatchElement.OutputBus; import static gregtech.api.enums.GT_HatchElement.OutputHatch; -import static gregtech.api.enums.GT_Values.V; import static gregtech.api.enums.GT_Values.VN; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE; @@ -46,13 +45,17 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.fluid.IFluidStore; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_OverclockCalculator; +import gregtech.api.util.GT_ParallelHelper; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -187,128 +190,29 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends } @Override - public boolean checkRecipe(ItemStack aStack) { - if (inputSeparation) { - FluidStack[] tFluids = getStoredFluids().toArray(new FluidStack[0]); - for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { - ArrayList<ItemStack> tInputs = new ArrayList<>(); - tBus.mRecipeMap = getRecipeMap(); - - if (isValidMetaTileEntity(tBus)) { - for (int i = tBus.getBaseMetaTileEntity() - .getSizeInventory() - 1; i >= 0; i--) { - if (tBus.getBaseMetaTileEntity() - .getStackInSlot(i) != null) { - tInputs.add( - tBus.getBaseMetaTileEntity() - .getStackInSlot(i)); - } - } - } - ItemStack[] tItems = tInputs.toArray(new ItemStack[0]); - if (processRecipe(tItems, tFluids)) { - return true; - } + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @Nonnull + @Override + protected GT_OverclockCalculator createOverclockCalculator(@Nonnull GT_Recipe recipe, + @Nonnull GT_ParallelHelper helper) { + |
