From fec1499f725be46b08abbb8c3413b9a72252731f Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Mon, 23 Dec 2024 10:21:35 -0600 Subject: [PATCH 01/15] Manual Trafo - Remove usages of deprecated stopMachine() - Switch to checkProcessing() from checkMachine() - Delete unused method onRunningTickTabbedMode() --- .../tileentities/multis/MTEManualTrafo.java | 50 +++++++++---------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/src/main/java/bartworks/common/tileentities/multis/MTEManualTrafo.java b/src/main/java/bartworks/common/tileentities/multis/MTEManualTrafo.java index 69fe99e45fb..2c9a22dd9b6 100644 --- a/src/main/java/bartworks/common/tileentities/multis/MTEManualTrafo.java +++ b/src/main/java/bartworks/common/tileentities/multis/MTEManualTrafo.java @@ -17,7 +17,6 @@ import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GTValues.V; 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; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE_GLOW; @@ -31,6 +30,8 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.StructureLibAPI; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.IStructureElementNoPlacement; @@ -45,9 +46,12 @@ import gregtech.api.metatileentity.implementations.MTEHatchDynamo; import gregtech.api.metatileentity.implementations.MTEHatchEnergy; import gregtech.api.metatileentity.implementations.MTETieredMachineBlock; +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.ShutDownReasonRegistry; public class MTEManualTrafo extends MTEEnhancedMultiBlockBase { @@ -158,7 +162,7 @@ public boolean isCorrectMachinePart(ItemStack itemStack) { @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (!this.getBaseMetaTileEntity() - .isAllowedToWork()) this.stopMachine(); + .isAllowedToWork()) this.stopMachine(ShutDownReasonRegistry.CRITICAL_NONE); super.onPostTick(aBaseMetaTileEntity, aTick); } @@ -166,7 +170,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { public boolean onRunningTick(ItemStack aStack) { if (!this.getBaseMetaTileEntity() .isAllowedToWork()) { - this.stopMachine(); + this.stopMachine(ShutDownReasonRegistry.CRITICAL_NONE); return false; } @@ -185,25 +189,6 @@ public boolean onRunningTick(ItemStack aStack) { this.getInputTier() * 2 * this.mEnergyHatches.size() * this.mEfficiency / this.getMaxEfficiency(null)); } - public boolean onRunningTickTabbedMode() { - boolean ret = false; - for (MTEHatchDynamo E : this.mDynamoHatches) { - for (MTEHatchEnergy I : this.mEnergyHatches) { - - long vtt = I.getEUVar() >= V[E.mTier] / 2 && E.getEUVar() < E.maxEUStore() ? I.getEUVar() : 0; - - if (vtt == 0) continue; - - long vtp = E.getEUVar() + vtt; - long avt = Math.min(vtp, E.maxEUStore()); - E.setEUVar(avt); - I.setEUVar(I.getEUVar() - vtt); - ret = true; - } - } - return ret; - } - @Override public long getInputTier() { if (!this.mEnergyHatches.isEmpty()) return GTUtility.getTier( @@ -223,13 +208,15 @@ public long getOutputTier() { } @Override - public boolean checkRecipe(ItemStack itemStack) { + public @NotNull CheckRecipeResult checkProcessing() { if (!this.getBaseMetaTileEntity() .isAllowedToWork()) { - this.stopMachine(); - return false; + this.stopMachine(ShutDownReasonRegistry.CRITICAL_NONE); + return CheckRecipeResultRegistry.NONE; } + + ItemStack itemStack = getControllerSlot(); if (itemStack == null || !itemStack.getUnlocalizedName() .startsWith("gt.integrated_circuit")) this.mode = 0; else this.mode = (byte) Math.min(3, itemStack.getItemDamage()); @@ -237,8 +224,17 @@ public boolean checkRecipe(ItemStack itemStack) { this.mProgresstime = 0; this.mMaxProgresstime = 1; this.mEfficiency = Math.max(this.mEfficiency, 100); - return this.upstep ? this.getOutputTier() - this.getInputTier() == this.mTiers - : this.getInputTier() - this.getOutputTier() == this.mTiers; + + if (this.upstep) { + if (this.getOutputTier() - this.getInputTier() == this.mTiers) { + return CheckRecipeResultRegistry.SUCCESSFUL; + } + } else { + if (this.getInputTier() - this.getOutputTier() == this.mTiers) { + return CheckRecipeResultRegistry.SUCCESSFUL; + } + } + return CheckRecipeResultRegistry.NO_RECIPE; } @Override From 62ca18d407eac768b81364034aee62497656f7ad Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Mon, 23 Dec 2024 10:43:21 -0600 Subject: [PATCH 02/15] Electric Implosion Compressor - Move away from deprecated stopMachine() override - Remove deprecated onWireCutterRightClick() usage - Cleanup spawnVisualPistonBlocks() and getAllBlockTiers() warnings --- .../MTEElectricImplosionCompressor.java | 39 ++++++++----------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/src/main/java/bartworks/common/tileentities/multis/MTEElectricImplosionCompressor.java b/src/main/java/bartworks/common/tileentities/multis/MTEElectricImplosionCompressor.java index 4eb7e37edc5..dd74cfc8364 100644 --- a/src/main/java/bartworks/common/tileentities/multis/MTEElectricImplosionCompressor.java +++ b/src/main/java/bartworks/common/tileentities/multis/MTEElectricImplosionCompressor.java @@ -50,6 +50,7 @@ import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.NotNull; +import com.google.common.collect.ImmutableList; import com.gtnewhorizon.structurelib.StructureLibAPI; import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; @@ -89,6 +90,7 @@ import gregtech.api.util.GTUtility; import gregtech.api.util.MultiblockTooltipBuilder; import gregtech.api.util.OverclockCalculator; +import gregtech.api.util.shutdown.ShutDownReason; public class MTEElectricImplosionCompressor extends MTEExtendedPowerMultiBlockBase implements ISurvivalConstructable { @@ -198,21 +200,15 @@ public PlaceResult survivalPlaceBlock(MTEElectricImplosionCompressor t, World wo .build(); public static List> getAllBlockTiers() { - return new ArrayList<>() { - - private static final long serialVersionUID = 8171991663102417651L; - - { - this.add(Pair.of(GregTechAPI.sBlockMetal5, 2)); - if (Mods.Avaritia.isModLoaded()) { - this.add(Pair.of(LudicrousBlocks.resource_block, 1)); - } - this.add(Pair.of(GregTechAPI.sBlockMetal9, 4)); - this.add(Pair.of(GregTechAPI.sBlockMetal9, 3)); - this.add(Pair.of(GregTechAPI.sBlockMetal9, 8)); - } - - }; + ImmutableList.Builder> b = new ImmutableList.Builder<>(); + b.add(Pair.of(GregTechAPI.sBlockMetal5, 2)); + if (Mods.Avaritia.isModLoaded()) { + b.add(Pair.of(LudicrousBlocks.resource_block, 1)); + } + b.add(Pair.of(GregTechAPI.sBlockMetal9, 4)); + b.add(Pair.of(GregTechAPI.sBlockMetal9, 3)); + b.add(Pair.of(GregTechAPI.sBlockMetal9, 8)); + return b.build(); } public static ITierConverter tieredBlockConverter() { @@ -374,9 +370,9 @@ public boolean isCorrectMachinePart(ItemStack itemStack) { } @Override - public void stopMachine() { + public void stopMachine(@NotNull ShutDownReason reason) { this.resetPiston(this.mBlockTier); - super.stopMachine(); + super.stopMachine(reason); } private void resetPiston(int tier) { @@ -427,13 +423,12 @@ private void animatePiston(IGregTechTileEntity aBaseMetaTileEntity) { aBaseMetaTileEntity.getWorld(), this.chunkCoordinates.get(2).posX, this.chunkCoordinates.get(2).posY, - this.chunkCoordinates.get(2).posZ, - 10); + this.chunkCoordinates.get(2).posZ); } @SideOnly(Side.CLIENT) - private void spawnVisualPistonBlocks(World world, int x, int y, int z, int age) { - EICPistonVisualizer pistonVisualizer = new EICPistonVisualizer(world, x, y, z, age); + private void spawnVisualPistonBlocks(World world, int x, int y, int z) { + EICPistonVisualizer pistonVisualizer = new EICPistonVisualizer(world, x, y, z, 10); Minecraft.getMinecraft().effectRenderer.addEffect(pistonVisualizer); } @@ -536,7 +531,7 @@ public boolean supportsBatchMode() { @Override public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, - float aX, float aY, float aZ) { + float aX, float aY, float aZ, ItemStack aTool) { if (aPlayer.isSneaking()) { batchMode = !batchMode; if (batchMode) { From 90c7e799ea38f439166e0f8c748ec8cc5dd136fe Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Mon, 23 Dec 2024 10:46:59 -0600 Subject: [PATCH 03/15] Microwave Grinder - Remove deprecated stopMachine() usage - Remove unnecessary cast - Remove 2 identical overrides --- .../metaTileEntity/multi/MTEMicrowave.java | 59 ++++++++----------- 1 file changed, 25 insertions(+), 34 deletions(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/MTEMicrowave.java b/src/main/java/tectech/thing/metaTileEntity/multi/MTEMicrowave.java index 63be95eaa52..c6b225b976a 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/MTEMicrowave.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/MTEMicrowave.java @@ -37,6 +37,7 @@ import gregtech.api.util.GTUtility; import gregtech.api.util.MultiblockTooltipBuilder; import gregtech.api.util.shutdown.ShutDownReason; +import gregtech.api.util.shutdown.ShutDownReasonRegistry; import tectech.Reference; import tectech.loader.MainLoader; import tectech.recipe.TTRecipeAdder; @@ -167,34 +168,34 @@ public void outputAfterRecipe_EM() { boolean inside = true; do { - for (Object entity : mte.getWorld() + for (Entity entity : mte.getWorld() .getEntitiesWithinAABBExcludingEntity(null, aabb)) { - if (entity instanceof Entity) { - if (tickedStuff.add((Entity) entity)) { - if (inside && entity instanceof EntityItem) { - GTRecipe tRecipe = RecipeMaps.microwaveRecipes.findRecipeQuery() - .items(((EntityItem) entity).getEntityItem()) - .voltage(128) - .notUnificated(true) - .find(); - if (tRecipe == null || tRecipe.mInputs.length == 0 || tRecipe.mInputs[0].stackSize != 1) { - itemsToOutput.add(((EntityItem) entity).getEntityItem()); - } else { - ItemStack newStuff = tRecipe.getOutput(0) - .copy(); - newStuff.stackSize = ((EntityItem) entity).getEntityItem().stackSize; - itemsToOutput.add(newStuff); - } - ((EntityItem) entity).delayBeforeCanPickup = 2; - ((EntityItem) entity).setDead(); - } else if (entity instanceof EntityLivingBase) { - if (!GTUtility.isWearingFullElectroHazmat((EntityLivingBase) entity)) { - ((EntityLivingBase) entity).attackEntityFrom(MainLoader.microwaving, damagingFactor); - } + + if (tickedStuff.add(entity)) { + if (inside && entity instanceof EntityItem) { + GTRecipe tRecipe = RecipeMaps.microwaveRecipes.findRecipeQuery() + .items(((EntityItem) entity).getEntityItem()) + .voltage(128) + .notUnificated(true) + .find(); + if (tRecipe == null || tRecipe.mInputs.length == 0 || tRecipe.mInputs[0].stackSize != 1) { + itemsToOutput.add(((EntityItem) entity).getEntityItem()); + } else { + ItemStack newStuff = tRecipe.getOutput(0) + .copy(); + newStuff.stackSize = ((EntityItem) entity).getEntityItem().stackSize; + itemsToOutput.add(newStuff); + } + ((EntityItem) entity).delayBeforeCanPickup = 2; + entity.setDead(); + } else if (entity instanceof EntityLivingBase) { + if (!GTUtility.isWearingFullElectroHazmat((EntityLivingBase) entity)) { + entity.attackEntityFrom(MainLoader.microwaving, damagingFactor); } } } } + aabb.offset(xyzOffsets.get0(), xyzOffsets.get1(), xyzOffsets.get2()); aabb = aabb.expand(xyzExpansion.get0() * 1.5, xyzExpansion.get1() * 1.5, xyzExpansion.get2() * 1.5); inside = false; @@ -206,7 +207,7 @@ public void outputAfterRecipe_EM() { if (remainingTime.get() <= 0) { mte.getWorld() .playSoundEffect(xPos, yPos, zPos, Reference.MODID + ":microwave_ding", 1, 1); - stopMachine(); + stopMachine(ShutDownReasonRegistry.NONE); } } @@ -320,18 +321,8 @@ public String[] getStructureDescription(ItemStack stackSize) { return description; } - @Override - public boolean isPowerPassButtonEnabled() { - return true; - } - @Override public boolean isSafeVoidButtonEnabled() { return false; } - - @Override - public boolean isAllowedToWorkButtonEnabled() { - return true; - } } From 62dcb0e3005fc719e27549fdc45dc3f9595d6001 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Mon, 23 Dec 2024 10:49:36 -0600 Subject: [PATCH 04/15] TTMultiblockBase - remove usage of deprecated stopMachine() --- .../thing/metaTileEntity/multi/base/TTMultiblockBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/base/TTMultiblockBase.java b/src/main/java/tectech/thing/metaTileEntity/multi/base/TTMultiblockBase.java index 911ae722aaf..aaf223479c4 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/base/TTMultiblockBase.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/base/TTMultiblockBase.java @@ -671,7 +671,7 @@ public float getExcessMassPerTick_EM(ItemStack itemStack) { * should do it */ protected void notAllowedToWork_stopMachine_EM() { - stopMachine(); + stopMachine(ShutDownReasonRegistry.NONE); } /** From ded21aac137a0f25fdec72240fba1fc0bea33611 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Mon, 23 Dec 2024 10:51:28 -0600 Subject: [PATCH 05/15] UCFE - remove usage and override of deprecated stopMachine() - Remove two unused methods - Remove one identical override --- .../MTEUniversalChemicalFuelEngine.java | 43 +++---------------- 1 file changed, 6 insertions(+), 37 deletions(-) diff --git a/src/main/java/goodgenerator/blocks/tileEntity/MTEUniversalChemicalFuelEngine.java b/src/main/java/goodgenerator/blocks/tileEntity/MTEUniversalChemicalFuelEngine.java index e39aa2e69ef..05bcb20e68b 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/MTEUniversalChemicalFuelEngine.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/MTEUniversalChemicalFuelEngine.java @@ -32,8 +32,6 @@ import gregtech.api.metatileentity.implementations.MTEHatch; import gregtech.api.metatileentity.implementations.MTEHatchDynamo; import gregtech.api.metatileentity.implementations.MTEHatchInput; -import gregtech.api.metatileentity.implementations.MTEHatchMaintenance; -import gregtech.api.metatileentity.implementations.MTEHatchMuffler; import gregtech.api.recipe.RecipeMap; import gregtech.api.recipe.RecipeMaps; import gregtech.api.recipe.check.CheckRecipeResult; @@ -43,6 +41,8 @@ import gregtech.api.util.GTRecipe; import gregtech.api.util.GTUtility; import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.shutdown.ShutDownReason; +import gregtech.api.util.shutdown.ShutDownReasonRegistry; import gtPlusPlus.api.recipe.GTPPRecipeMaps; import tectech.thing.metaTileEntity.hatch.MTEHatchDynamoMulti; @@ -71,32 +71,6 @@ public MTEUniversalChemicalFuelEngine(int id, String name, String nameRegional) super.useLongPower = true; } - public final boolean addMaintenance(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof MTEHatchMaintenance) { - ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return this.mMaintenanceHatches.add((MTEHatchMaintenance) aMetaTileEntity); - } - } - return false; - } - - public final boolean addMuffler(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof MTEHatchMuffler) { - ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return this.mMufflerHatches.add((MTEHatchMuffler) aMetaTileEntity); - } - } - return false; - } - public final boolean addInputHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { if (aTileEntity == null) { return false; @@ -167,11 +141,6 @@ public String[] getStructureDescription(ItemStack itemStack) { return DescTextLocalization.addText("UniversalChemicalFuelEngine.hint", 11); } - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - @Override public int getPollutionPerSecond(ItemStack aStack) { return (int) Math.sqrt(this.getPowerFlow()); @@ -248,10 +217,10 @@ protected CheckRecipeResult processFuel(ArrayList tFluids, RecipeMap } @Override - public void stopMachine() { + public void stopMachine(@NotNull ShutDownReason reason) { // Reset the counter for heating, so that it works again when the machine restarts heatingTicks = 0; - super.stopMachine(); + super.stopMachine(reason); } @Override @@ -301,7 +270,7 @@ void addAutoEnergy() { tHatch.getBaseMetaTileEntity() .getStoredEU() + exEU)); } else if (!isStoppingSafe) { - stopMachine(); + stopMachine(ShutDownReasonRegistry.NONE); } } if (!eDynamoMulti.isEmpty()) { @@ -313,7 +282,7 @@ void addAutoEnergy() { tHatch.getBaseMetaTileEntity() .getStoredEU() + exEU)); } else if (!isStoppingSafe) { - stopMachine(); + stopMachine(ShutDownReasonRegistry.NONE); } } } From cbf7589d4048729e83aabf21c6943ace1cf0d7af Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Mon, 23 Dec 2024 10:53:34 -0600 Subject: [PATCH 06/15] Research Completer - Use checkProcessing() over checkRecipe() - Fix cast warning --- .../machines/multi/MTEResearchCompleter.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTEResearchCompleter.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTEResearchCompleter.java index 65e65c664ab..4b69a930099 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTEResearchCompleter.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTEResearchCompleter.java @@ -11,6 +11,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; @@ -23,6 +25,8 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.MTEEnhancedMultiBlockBase; import gregtech.api.net.GTPacketNodeInfo; +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; @@ -169,8 +173,7 @@ public boolean onRunningTick(ItemStack aStack) { TileEntity tileEntity = aBaseMetaTileEntity.getWorld() .getTileEntity(nodeX, nodeY, nodeZ); - if (tileEntity instanceof TileNode) { - TileNode aNode = (TileNode) tileEntity; + if (tileEntity instanceof TileNode aNode) { AspectList aspectsBase = aNode.getAspectsBase(); for (Aspect aspect : aspectsBase.getAspects()) { @@ -227,7 +230,7 @@ public boolean isCorrectMachinePart(ItemStack itemStack) { } @Override - public boolean checkRecipe(ItemStack itemStack) { + public @NotNull CheckRecipeResult checkProcessing() { ArrayList tInputList = this.getStoredInputs(); for (ItemStack stack : tInputList) { @@ -248,7 +251,7 @@ public boolean checkRecipe(ItemStack itemStack) { this.getMaxInputVoltage(), false); if (this.mMaxProgresstime == 2147483646 && this.mEUt == 2147483646) { - return false; + return CheckRecipeResultRegistry.NO_RECIPE; } if (this.mEUt > 0) { this.mEUt = -this.mEUt; @@ -267,12 +270,12 @@ public boolean checkRecipe(ItemStack itemStack) { this.sendLoopStart((byte) 20); this.updateSlots(); - return true; + return CheckRecipeResultRegistry.SUCCESSFUL; } } } - return false; + return CheckRecipeResultRegistry.NO_RECIPE; } @Override From e4fcb1133cf29cc2994d096f6a07a5391b0ed6f6 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Mon, 23 Dec 2024 10:59:50 -0600 Subject: [PATCH 07/15] Windmill - Move to checkProcessing() over checkRecipe() - Move away from deprecated stopMachine() - Clean up try-catch methods --- .../tileentities/multis/MTEWindmill.java | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/main/java/bartworks/common/tileentities/multis/MTEWindmill.java b/src/main/java/bartworks/common/tileentities/multis/MTEWindmill.java index f86c2a9cc86..0f113eecada 100644 --- a/src/main/java/bartworks/common/tileentities/multis/MTEWindmill.java +++ b/src/main/java/bartworks/common/tileentities/multis/MTEWindmill.java @@ -40,6 +40,8 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.StructureLibAPI; import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; @@ -77,11 +79,14 @@ import gregtech.api.metatileentity.implementations.MTEEnhancedMultiBlockBase; import gregtech.api.objects.ItemData; import gregtech.api.recipe.RecipeMaps; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.render.TextureFactory; import gregtech.api.util.GTOreDictUnificator; import gregtech.api.util.GTRecipe; import gregtech.api.util.GTUtility; import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.shutdown.ShutDownReason; import gregtech.common.items.IDMetaTool01; import gregtech.common.items.MetaGeneratedTool01; @@ -277,8 +282,9 @@ private float[] multiplierRecipe(ItemStack itemStack) { } @Override - public boolean checkRecipe(ItemStack itemStack) { - if (itemStack == null || itemStack.getItem() == null) return false; + public @NotNull CheckRecipeResult checkProcessing() { + ItemStack itemStack = getControllerSlot(); + if (itemStack == null || itemStack.getItem() == null) return CheckRecipeResultRegistry.NO_RECIPE; if (this.mOutputItems == null) this.mOutputItems = new ItemStack[2]; @@ -287,7 +293,7 @@ public boolean checkRecipe(ItemStack itemStack) { .voltage(V[1]) .find(); if (tRecipe == null) { - return false; + return CheckRecipeResultRegistry.NO_RECIPE; } if (tRecipe.getOutput(0) != null) { @@ -325,11 +331,11 @@ public boolean checkRecipe(ItemStack itemStack) { } this.mMaxProgresstime = tRecipe.mDuration * 2 * 100 * this.mMulti / this.getSpeed(this.rotorBlock); this.mMulti = 16; - return true; + return CheckRecipeResultRegistry.SUCCESSFUL; } @Override - public void stopMachine() { + public void stopMachine(@NotNull ShutDownReason reason) { this.getBaseMetaTileEntity() .disableWorking(); } @@ -518,30 +524,28 @@ public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBu } public float OutputMultiplier(TileEntityRotorBlock rotorBlock) { - try { - return ((ItemStonageRotors) rotorBlock.rotorSlot.get() - .getItem()).getmRotor(); - } catch (Exception e) { - return 1f; + ItemStack stack = rotorBlock.rotorSlot.get(); + if (stack == null || !(stack.getItem() instanceof ItemStonageRotors rotor)) { + return 1; } + return rotor.getmRotor(); } public int getSpeed(TileEntityRotorBlock rotorBlock) { - try { - return ((ItemStonageRotors) rotorBlock.rotorSlot.get() - .getItem()).getSpeed(); - } catch (Exception e) { + ItemStack stack = rotorBlock.rotorSlot.get(); + if (stack == null || !(stack.getItem() instanceof ItemStonageRotors rotor)) { return 1; } + return rotor.getSpeed(); } public void setRotorDamage(TileEntityRotorBlock rotorBlock, int damage) { - try { - ((ItemStonageRotors) rotorBlock.rotorSlot.get() - .getItem()).damageItemStack(rotorBlock.rotorSlot.get(), damage); - } catch (Exception e) { + ItemStack stack = rotorBlock.rotorSlot.get(); + if (stack == null || !(stack.getItem() instanceof ItemStonageRotors rotor)) { rotorBlock.rotorSlot.damage(damage, false); + return; } + rotor.damageItemStack(stack, damage); } @Override From e6f4efc08c92eb8bf0294dfb8f2a8fcd8afa8e23 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Mon, 23 Dec 2024 11:04:35 -0600 Subject: [PATCH 08/15] TFFT - move to checkProcessing() over checkRecipe() - remove 1 method identical to super --- .../kekztech/common/tileentities/MTETankTFFT.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/kekztech/common/tileentities/MTETankTFFT.java b/src/main/java/kekztech/common/tileentities/MTETankTFFT.java index 39c2c4d9a68..7311c4e6717 100644 --- a/src/main/java/kekztech/common/tileentities/MTETankTFFT.java +++ b/src/main/java/kekztech/common/tileentities/MTETankTFFT.java @@ -33,6 +33,8 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.StructureLibAPI; import com.gtnewhorizon.structurelib.alignment.constructable.ChannelDataAccessor; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; @@ -52,6 +54,8 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.MTEEnhancedMultiBlockBase; import gregtech.api.metatileentity.implementations.MTEHatchOutput; +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.IGTHatchAdder; @@ -432,12 +436,13 @@ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack a } @Override - public boolean checkRecipe(ItemStack itemStack) { + public @NotNull CheckRecipeResult checkProcessing() { mEfficiency = getCurrentEfficiency(null); mEfficiencyIncrease = 10000; mEUt = this.runningCost; mMaxProgresstime = 20; + ItemStack itemStack = getControllerSlot(); this.fluidSelector = (itemStack != null && itemStack.getItem() instanceof ItemIntegratedCircuit) ? (byte) itemStack.getItemDamage() : -1; @@ -504,7 +509,7 @@ public boolean checkRecipe(ItemStack itemStack) { if (this.mEUt > 0) this.mEUt = -this.mEUt; - return true; + return CheckRecipeResultRegistry.SUCCESSFUL; } @Override @@ -582,11 +587,6 @@ public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); } - @Override - public boolean isGivingInformation() { - return true; - } - @Override public int getMaxEfficiency(ItemStack stack) { return 10000; From e1204e37b3a199bc3be42f43370e546927f10d7d Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Mon, 23 Dec 2024 11:07:29 -0600 Subject: [PATCH 09/15] LESU - Use checkProcessing() over checkRecipe() - Remove 1 method identical to super --- .../common/tileentities/multis/MTELESU.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/bartworks/common/tileentities/multis/MTELESU.java b/src/main/java/bartworks/common/tileentities/multis/MTELESU.java index 4d91348abb3..0320ecfcd0f 100644 --- a/src/main/java/bartworks/common/tileentities/multis/MTELESU.java +++ b/src/main/java/bartworks/common/tileentities/multis/MTELESU.java @@ -28,6 +28,8 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizons.modularui.api.NumberFormatMUI; import com.gtnewhorizons.modularui.api.drawable.Text; import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; @@ -59,6 +61,8 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.MTEMultiBlockBase; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.render.TextureFactory; import gregtech.api.util.GTUtility; @@ -140,11 +144,6 @@ public long maxEUOutput() { return Math.min(Math.max(this.mStorage / Configuration.multiblocks.energyPerCell, 1L), 32768L); } - @Override - public int rechargerSlotStartIndex() { - return 0; - } - @Override public int rechargerSlotCount() { return 1; @@ -312,8 +311,8 @@ public boolean isCorrectMachinePart(ItemStack itemStack) { } @Override - public boolean checkRecipe(ItemStack itemStack) { - return true; + public @NotNull CheckRecipeResult checkProcessing() { + return CheckRecipeResultRegistry.SUCCESSFUL; } @Override From b7baffd40bfbdb05621b04b23b50426570aee43e Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Mon, 23 Dec 2024 11:09:41 -0600 Subject: [PATCH 10/15] HTGR - Use checkProcessing() over checkRecipe() - Remove usage of deprecated stopMachine() and criticalStopMachine() --- .../multis/MTEHighTempGasCooledReactor.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main/java/bartworks/common/tileentities/multis/MTEHighTempGasCooledReactor.java b/src/main/java/bartworks/common/tileentities/multis/MTEHighTempGasCooledReactor.java index 7261876bfbf..e8bcc2bd5b5 100644 --- a/src/main/java/bartworks/common/tileentities/multis/MTEHighTempGasCooledReactor.java +++ b/src/main/java/bartworks/common/tileentities/multis/MTEHighTempGasCooledReactor.java @@ -30,6 +30,8 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; @@ -51,10 +53,13 @@ import gregtech.api.metatileentity.implementations.MTEHatchInput; import gregtech.api.metatileentity.implementations.MTEHatchOutputBus; 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.GTLanguageManager; import gregtech.api.util.GTUtility; import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.shutdown.ShutDownReasonRegistry; public class MTEHighTempGasCooledReactor extends MTEEnhancedMultiBlockBase { @@ -257,23 +262,23 @@ protected boolean filtersFluid() { } @Override - public boolean checkRecipe(ItemStack controllerStack) { + public @NotNull CheckRecipeResult checkProcessing() { if (this.empty) { if (this.HeliumSupply > 0 || this.fuelsupply > 0) { this.mEfficiency = 10000; this.mMaxProgresstime = 100; - return true; + return CheckRecipeResultRegistry.SUCCESSFUL; } - return false; + return CheckRecipeResultRegistry.NO_RECIPE; } if (this.HeliumSupply < MTEHighTempGasCooledReactor.HELIUM_NEEDED || this.fuelsupply < mincapacity) - return false; + return CheckRecipeResultRegistry.NO_RECIPE; double eff = Math.min(Math.pow((double) this.fuelsupply / (double) mincapacity, 2D), 100D) / 100D - (this.getIdealStatus() - this.getRepairStatus()) / 10D; - if (eff <= 0) return false; + if (eff <= 0) return CheckRecipeResultRegistry.NO_RECIPE; int toReduce = MathUtils.floorInt(this.fuelsupply * 0.025D * eff); @@ -285,7 +290,7 @@ public boolean checkRecipe(ItemStack controllerStack) { ItemStack[] toOutput = { new ItemStack(HTGRMaterials.aHTGR_Materials, burnedballs, meta), new ItemStack(HTGRMaterials.aHTGR_Materials, toReduce, meta + 1) }; - if (!this.canOutputAll(toOutput)) return false; + if (!this.canOutputAll(toOutput)) return CheckRecipeResultRegistry.NO_RECIPE; this.fuelsupply -= originalToReduce; this.mOutputItems = toOutput; @@ -298,7 +303,7 @@ public boolean checkRecipe(ItemStack controllerStack) { this.mEfficiencyIncrease = 0; this.mEUt = -powerUsage; this.mMaxProgresstime = (int) (72000 * (1d - eff / 2d)); - return true; + return CheckRecipeResultRegistry.SUCCESSFUL; } private int runningtick = 0; @@ -344,7 +349,7 @@ public boolean onRunningTick(ItemStack aStack) { } // USE DA POWAH if (!this.drainEnergyInput(-this.mEUt)) { - this.criticalStopMachine(); + this.stopMachine(ShutDownReasonRegistry.CRITICAL_NONE); return false; } @@ -366,7 +371,7 @@ public boolean onRunningTick(ItemStack aStack) { this.updateSlots(); - if (takecoolant > 0) this.stopMachine(); + if (takecoolant > 0) this.stopMachine(ShutDownReasonRegistry.NONE); } return true; From bdeb96070b75a515ef7b52505f22a852f8e41020 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Mon, 23 Dec 2024 11:20:41 -0600 Subject: [PATCH 11/15] LSC - Use checkProcessing() over deprecated checkRecipe() - Remove override identical to super - Two warnings for lambda usage --- .../MTELapotronicSuperCapacitor.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/kekztech/common/tileentities/MTELapotronicSuperCapacitor.java b/src/main/java/kekztech/common/tileentities/MTELapotronicSuperCapacitor.java index 1bffe0045d2..0de97fe1d5f 100644 --- a/src/main/java/kekztech/common/tileentities/MTELapotronicSuperCapacitor.java +++ b/src/main/java/kekztech/common/tileentities/MTELapotronicSuperCapacitor.java @@ -41,6 +41,8 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import org.jetbrains.annotations.NotNull; + import com.google.common.collect.ImmutableList; import com.gtnewhorizon.structurelib.StructureLibAPI; import com.gtnewhorizon.structurelib.alignment.constructable.ChannelDataAccessor; @@ -76,6 +78,8 @@ import gregtech.api.metatileentity.implementations.MTEHatchDynamo; import gregtech.api.metatileentity.implementations.MTEHatchEnergy; import gregtech.api.metatileentity.implementations.MTEHatchMaintenance; +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.IGTHatchAdder; @@ -543,12 +547,12 @@ public boolean isCorrectMachinePart(ItemStack stack) { } @Override - public boolean checkRecipe(ItemStack stack) { + public @NotNull CheckRecipeResult checkProcessing() { this.mProgresstime = 1; this.mMaxProgresstime = 1; this.mEUt = 0; this.mEfficiencyIncrease = 10000; - return true; + return CheckRecipeResultRegistry.SUCCESSFUL; } @Override @@ -1146,7 +1150,7 @@ && getBaseMetaTileEntity().wasShutdown())) .setTextAlignment(Alignment.CenterLeft) .setDefaultColor(COLOR_TEXT_WHITE.get()) .setEnabled(widget -> isActiveCache)) - .widget(new FakeSyncWidget.LongSyncer(() -> energyInputValues.avgLong(), val -> avgInCache = val)) + .widget(new FakeSyncWidget.LongSyncer(energyInputValues::avgLong, val -> avgInCache = val)) .widget( new TextWidget() .setStringSupplier( @@ -1158,7 +1162,7 @@ && getBaseMetaTileEntity().wasShutdown())) .setTextAlignment(Alignment.CenterLeft) .setDefaultColor(COLOR_TEXT_WHITE.get()) .setEnabled(widget -> isActiveCache)) - .widget(new FakeSyncWidget.LongSyncer(() -> energyOutputValues.avgLong(), val -> avgOutCache = val)) + .widget(new FakeSyncWidget.LongSyncer(energyOutputValues::avgLong, val -> avgOutCache = val)) .widget( new TextWidget().setStringSupplier(() -> EnumChatFormatting.WHITE + timeToCache) .setTextAlignment(Alignment.CenterLeft) @@ -1220,11 +1224,6 @@ public void loadNBTData(NBTTagCompound nbt) { super.loadNBTData(nbt); } - @Override - public boolean isGivingInformation() { - return true; - } - @Override public int getMaxEfficiency(ItemStack stack) { return 10000; From 5c525e33b6908a6ad156160285d2be2f2df204c3 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Mon, 23 Dec 2024 12:20:24 -0600 Subject: [PATCH 12/15] LINAC - Use checkProcessing() over checkRecipe() - Remove deprecated stopMachine() override --- .../gtnhlanth/common/tileentity/MTELINAC.java | 36 ++++++++----------- 1 file changed, 15 insertions(+), 21 deletions(-) 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; From 17a1cab26c6680bdfb360baa161f0083f205bc68 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Mon, 23 Dec 2024 12:20:49 -0600 Subject: [PATCH 13/15] Source Chamber - Use checkProcessing() over checkRecipe() - Move away from deprecated stopMachine() --- .../common/tileentity/MTESourceChamber.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) 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 From 6d762439396e841ad63c0e4ee877a34a692dec48 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Mon, 23 Dec 2024 12:21:10 -0600 Subject: [PATCH 14/15] Synchotron - Use checkProcessing() over checkRecipe() - Remove deprecated stopMachine() override --- .../common/tileentity/MTESynchrotron.java | 44 ++++++++----------- 1 file changed, 18 insertions(+), 26 deletions(-) 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 Date: Mon, 23 Dec 2024 12:21:21 -0600 Subject: [PATCH 15/15] Target Chamber - Use checkProcessing() over checkRecipe() --- .../common/tileentity/MTETargetChamber.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/main/java/gtnhlanth/common/tileentity/MTETargetChamber.java b/src/main/java/gtnhlanth/common/tileentity/MTETargetChamber.java index 988bf1fd5c6..f7f413f907e 100644 --- a/src/main/java/gtnhlanth/common/tileentity/MTETargetChamber.java +++ b/src/main/java/gtnhlanth/common/tileentity/MTETargetChamber.java @@ -24,6 +24,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; @@ -38,6 +40,8 @@ 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.GTRecipe; import gregtech.api.util.GTUtility; @@ -226,8 +230,9 @@ public RecipeMap 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() {