diff --git a/src/main/java/gtnhlanth/common/tileentity/MTELINAC.java b/src/main/java/gtnhlanth/common/tileentity/MTELINAC.java index 8fb3a54e921..fa760dda9df 100644 --- a/src/main/java/gtnhlanth/common/tileentity/MTELINAC.java +++ b/src/main/java/gtnhlanth/common/tileentity/MTELINAC.java @@ -25,6 +25,8 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.StructureLib; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -40,6 +42,8 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.MTEEnhancedMultiBlockBase; import gregtech.api.metatileentity.implementations.MTEHatchEnergy; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.render.TextureFactory; import gregtech.api.util.GTUtility; import gregtech.api.util.MultiblockTooltipBuilder; @@ -246,8 +250,9 @@ private boolean addBeamLineOutputHatch(IGregTechTileEntity te, int casingIndex) return false; } + @NotNull @Override - public boolean checkRecipe(ItemStack itemStack) { + public CheckRecipeResult checkProcessing() { float tempFactor = 0; // Focus as determined by multi properties @@ -277,7 +282,7 @@ public boolean checkRecipe(ItemStack itemStack) { if (tFluidInputs.isEmpty()) { this.doRandomMaintenanceDamage(); // Penalise letting coolant run dry this.stopMachine(SimpleShutDownReason.ofCritical("gtnhlanth.nocoolant")); - return false; + return CheckRecipeResultRegistry.NO_RECIPE; } // Coolant input @@ -291,12 +296,12 @@ public boolean checkRecipe(ItemStack itemStack) { this.mEfficiencyIncrease = 10000; if (this.getInputInformation() == null) { - return false; + return CheckRecipeResultRegistry.NO_RECIPE; } if (this.getInputInformation() .getEnergy() == 0) { - return false; + return CheckRecipeResultRegistry.NO_RECIPE; } particleId = this.getInputInformation() @@ -305,7 +310,7 @@ public boolean checkRecipe(ItemStack itemStack) { if (!inputParticle.canAccelerate()) { stopMachine(SimpleShutDownReason.ofCritical("gtnhlanth.noaccel")); - return false; + return CheckRecipeResultRegistry.NO_RECIPE; } mMaxProgresstime = 1 * TickTime.SECOND; @@ -364,7 +369,7 @@ public boolean checkRecipe(ItemStack itemStack) { if (Util.coolantFluidCheck(primFluid, fluidConsumed)) { this.stopMachine(SimpleShutDownReason.ofCritical("gtnhlanth.inscoolant")); - return false; + return CheckRecipeResultRegistry.NO_RECIPE; } @@ -374,17 +379,17 @@ public boolean checkRecipe(ItemStack itemStack) { primFluid.getFluid() .getName()); - if (Objects.isNull(fluidOutput)) return false; + if (Objects.isNull(fluidOutput)) return CheckRecipeResultRegistry.NO_RECIPE; FluidStack fluidOutputStack = new FluidStack(fluidOutput, fluidConsumed); - if (Objects.isNull(fluidOutputStack)) return false; + if (Objects.isNull(fluidOutputStack)) return CheckRecipeResultRegistry.NO_RECIPE; this.addFluidOutputs(new FluidStack[] { fluidOutputStack }); outputAfterRecipe(); - return true; + return CheckRecipeResultRegistry.SUCCESSFUL; } private void outputAfterRecipe() { @@ -402,18 +407,7 @@ private void outputAfterRecipe() { } @Override - public void stopMachine() { - - outputFocus = 0; - outputEnergy = 0; - outputParticle = 0; - outputRate = 0; - machineTemp = 0; - super.stopMachine(); - } - - @Override - public void stopMachine(ShutDownReason reason) { + public void stopMachine(@NotNull ShutDownReason reason) { outputFocus = 0; outputEnergy = 0; diff --git a/src/main/java/gtnhlanth/common/tileentity/MTESourceChamber.java b/src/main/java/gtnhlanth/common/tileentity/MTESourceChamber.java index 5c69bae5a8f..4e05e4220ea 100644 --- a/src/main/java/gtnhlanth/common/tileentity/MTESourceChamber.java +++ b/src/main/java/gtnhlanth/common/tileentity/MTESourceChamber.java @@ -22,6 +22,8 @@ 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; @@ -35,9 +37,12 @@ import gregtech.api.metatileentity.implementations.MTEEnhancedMultiBlockBase; import gregtech.api.metatileentity.implementations.MTEHatchEnergy; import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.render.TextureFactory; import gregtech.api.util.GTUtility; import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.shutdown.ShutDownReason; import gregtech.api.util.shutdown.SimpleShutDownReason; import gtnhlanth.common.beamline.BeamInformation; import gtnhlanth.common.beamline.BeamLinePacket; @@ -155,8 +160,9 @@ private boolean addBeamLineOutputHatch(IGregTechTileEntity te, int casingIndex) return false; } + @NotNull @Override - public boolean checkRecipe(ItemStack itemStack) { + public CheckRecipeResult checkProcessing() { // No input particle, so no input quantities @@ -176,15 +182,17 @@ public boolean checkRecipe(ItemStack itemStack) { .voltage(tVoltageActual) .find(); - if (tRecipe == null || !tRecipe.isRecipeInputEqual(true, new FluidStack[] {}, tItems)) return false; // Consumes - // input - // item + if (tRecipe == null || !tRecipe.isRecipeInputEqual(true, new FluidStack[] {}, tItems)) { + return CheckRecipeResultRegistry.NO_RECIPE; // Consumes input item + } this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; this.mMaxProgresstime = tRecipe.mDuration; - if (mMaxProgresstime == Integer.MAX_VALUE - 1 && this.mEUt == Integer.MAX_VALUE - 1) return false; + if (mMaxProgresstime == Integer.MAX_VALUE - 1 && this.mEUt == Integer.MAX_VALUE - 1) { + return CheckRecipeResultRegistry.NO_RECIPE; + } mEUt = (int) -tVoltageActual; if (this.mEUt > 0) this.mEUt = (-this.mEUt); @@ -203,7 +211,7 @@ public boolean checkRecipe(ItemStack itemStack) { if (outputEnergy <= 0) { stopMachine(SimpleShutDownReason.ofCritical("gtnhlanth.scerror")); - return false; + return CheckRecipeResultRegistry.NO_RECIPE; } outputFocus = tRecipe.focus; @@ -214,7 +222,7 @@ public boolean checkRecipe(ItemStack itemStack) { outputAfterRecipe(); - return true; + return CheckRecipeResultRegistry.SUCCESSFUL; } @Override @@ -238,12 +246,12 @@ private void outputAfterRecipe() { } @Override - public void stopMachine() { + public void stopMachine(@NotNull ShutDownReason reason) { outputFocus = 0; outputEnergy = 0; outputParticle = 0; outputRate = 0; - super.stopMachine(); + super.stopMachine(reason); } @Override diff --git a/src/main/java/gtnhlanth/common/tileentity/MTESynchrotron.java b/src/main/java/gtnhlanth/common/tileentity/MTESynchrotron.java index 2d8f0c2f08f..c9e0cf75b96 100644 --- a/src/main/java/gtnhlanth/common/tileentity/MTESynchrotron.java +++ b/src/main/java/gtnhlanth/common/tileentity/MTESynchrotron.java @@ -28,6 +28,8 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import com.google.common.collect.ImmutableMap; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -44,6 +46,8 @@ import gregtech.api.metatileentity.implementations.MTEExtendedPowerMultiBlockBase; import gregtech.api.metatileentity.implementations.MTEHatch; import gregtech.api.metatileentity.implementations.MTEHatchEnergy; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.render.TextureFactory; import gregtech.api.util.ExoticEnergyInputHelper; import gregtech.api.util.GTUtility; @@ -445,7 +449,7 @@ public class MTESynchrotron extends MTEExtendedPowerMultiBlockBase getRecipeMap() { return BeamlineRecipeAdder2.instance.TargetChamberRecipes; } + @NotNull @Override - public boolean checkRecipe(ItemStack itemStack) { + public CheckRecipeResult checkProcessing() { inputEnergy = 0; inputRate = 0; @@ -272,25 +277,26 @@ public boolean checkRecipe(ItemStack itemStack) { }) .find(); - if (tRecipe == null) return false; + if (tRecipe == null) return CheckRecipeResultRegistry.NO_RECIPE; BeamInformation inputInfo = this.getInputInformation(); - if (inputInfo == null) return false; + if (inputInfo == null) return CheckRecipeResultRegistry.NO_RECIPE; inputEnergy = inputInfo.getEnergy(); inputRate = inputInfo.getRate(); inputParticle = inputInfo.getParticleId(); inputFocus = inputInfo.getFocus(); - if (inputEnergy < tRecipe.minEnergy || inputEnergy > tRecipe.maxEnergy) return false; + if (inputEnergy < tRecipe.minEnergy || inputEnergy > tRecipe.maxEnergy) + return CheckRecipeResultRegistry.NO_RECIPE; - if (inputFocus < tRecipe.minFocus) return false; + if (inputFocus < tRecipe.minFocus) return CheckRecipeResultRegistry.NO_RECIPE; - if (inputParticle != tRecipe.particleId) return false; + if (inputParticle != tRecipe.particleId) return CheckRecipeResultRegistry.NO_RECIPE; if (tRecipe.focusItem != null) { - if (tRecipe.focusItem.getItem() != tFocusItem.getItem()) return false; + if (tRecipe.focusItem.getItem() != tFocusItem.getItem()) return CheckRecipeResultRegistry.NO_RECIPE; } int focusDurabilityDepletion = 1; @@ -321,13 +327,14 @@ public boolean checkRecipe(ItemStack itemStack) { // over the rate. E.g., 100a, 10r // would equal 50 seconds - if (this.mMaxProgresstime == Integer.MAX_VALUE - 1 && this.mEUt == Integer.MAX_VALUE - 1) return false; + if (this.mMaxProgresstime == Integer.MAX_VALUE - 1 && this.mEUt == Integer.MAX_VALUE - 1) + return CheckRecipeResultRegistry.NO_RECIPE; double maxParallel = tRecipe .maxParallelCalculatedByInputs(batchAmount, new FluidStack[] {}, tItemsWithFocusItemArray); if (maxParallel < 1) // Insufficient items - return false; + return CheckRecipeResultRegistry.NO_RECIPE; if (batchAmount > maxParallel) batchAmount = (int) maxParallel; @@ -358,7 +365,7 @@ public boolean checkRecipe(ItemStack itemStack) { this.updateSlots(); - return true; + return CheckRecipeResultRegistry.SUCCESSFUL; } private BeamInformation getInputInformation() {