From dc25b04bd59b064026040d68926d54bc601b6ed2 Mon Sep 17 00:00:00 2001 From: HoleFish <48403212+HoleFish@users.noreply.github.com> Date: Wed, 20 Mar 2024 17:13:11 +0800 Subject: Implement shutdown reason mechanism (#853) * migrate machines * add annotation * damn animation --- .../base/GregtechMeta_SteamMultiBase.java | 8 ++---- ...techMetaTileEntity_IndustrialVacuumFreezer.java | 8 ++++-- .../advanced/GregtechMetaTileEntity_Adv_EBF.java | 7 ++++- .../production/GregtechMTE_NuclearReactor.java | 3 ++- .../GregtechMetaTileEntity_LargeRocketEngine.java | 3 ++- ...techMetaTileEntity_QuantumForceTransformer.java | 12 +++++---- .../turbines/GT_MTE_LargeTurbine_Plasma.java | 5 ++-- .../GregtechMetaTileEntity_LargerTurbineBase.java | 31 +++++++++++----------- 8 files changed, 43 insertions(+), 34 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java index 55288bc85c..2dafe59cd8 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java @@ -27,6 +27,7 @@ import gregtech.api.recipe.RecipeMap; import gregtech.api.util.GT_HatchElementBuilder; import gregtech.api.util.GT_Utility; import gregtech.api.util.IGT_HatchAdder; +import gregtech.api.util.shutdown.ShutDownReasonRegistry; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Steam_BusInput; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Steam_BusOutput; @@ -135,7 +136,7 @@ public abstract class GregtechMeta_SteamMultiBase 0 || !areAllTurbinesTheSame()) { - stopMachine(); + stopMachine(ShutDownReasonRegistry.NO_TURBINE); return CheckRecipeResultRegistry.NO_TURBINE_FOUND; } @@ -163,7 +164,7 @@ public class GT_MTE_LargeTurbine_Plasma extends GregtechMetaTileEntity_LargerTur optFlow = MathUtils.roundToClosestInt(aTotalOptimalFlow); euPerTurbine = MathUtils.roundToClosestInt(aEUPerTurbine); if (optFlow <= 0 || baseEff <= 0) { - stopMachine(); // in case the turbine got removed + stopMachine(ShutDownReasonRegistry.NONE); // in case the turbine got removed return CheckRecipeResultRegistry.NO_FUEL_FOUND; } } else { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java index 92995a831b..adb35cc0dd 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java @@ -45,6 +45,8 @@ import gregtech.api.recipe.check.CheckRecipeResult; import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Utility; +import gregtech.api.util.shutdown.ShutDownReason; +import gregtech.api.util.shutdown.ShutDownReasonRegistry; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.BlockPos; @@ -438,7 +440,7 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends } if (getEmptyTurbineAssemblies().size() > 0 || !areAllTurbinesTheSame()) { - stopMachine(); + stopMachine(ShutDownReasonRegistry.NO_TURBINE); return CheckRecipeResultRegistry.NO_TURBINE_FOUND; } @@ -474,7 +476,7 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends baseEff = MathUtils.roundToClosestInt(aTotalBaseEff); optFlow = MathUtils.roundToClosestInt(aTotalOptimalFlow); if (optFlow <= 0 || baseEff <= 0) { - stopMachine(); // in case the turbine got removed + stopMachine(ShutDownReasonRegistry.NONE); // in case the turbine got removed return CheckRecipeResultRegistry.NO_FUEL_FOUND; } } else { @@ -518,10 +520,11 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends @Override public boolean doRandomMaintenanceDamage() { - if (getMaxParallelRecipes() == 0 || getRepairStatus() == 0) { - stopMachine(); + if (getMaxParallelRecipes() == 0) { + stopMachine(ShutDownReasonRegistry.NO_TURBINE); return false; } + if (mRuntime++ > 1000) { mRuntime = 0; @@ -732,27 +735,23 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); if (aBaseMetaTileEntity.isServerSide()) { - if (mUpdate == 1 || mStartUpCheck == 1) { - log("Cleared Rotor Assemblies."); - this.mTurbineRotorHatches.clear(); + if (this.maxProgresstime() > 0 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()) { + enableAllTurbineHatches(); + } + if (this.maxProgresstime() <= 0) { + stopMachine(ShutDownReasonRegistry.NONE); } - } - super.onPostTick(aBaseMetaTileEntity, aTick); - if (this.maxProgresstime() > 0 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()) { - enableAllTurbineHatches(); - } - if (this.maxProgresstime() <= 0) { - stopMachine(); } } @Override - public void stopMachine() { + public void stopMachine(@NotNull ShutDownReason reason) { baseEff = 0; optFlow = 0; disableAllTurbineHatches(); - super.stopMachine(); + super.stopMachine(reason); } @Override -- cgit