diff options
| author | Maxim <maxim235@gmx.de> | 2023-07-17 10:21:49 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-17 10:21:49 +0200 |
| commit | 328376ff618b14aac4ba57d790066129c8ad95e8 (patch) | |
| tree | 9a59d8ff7708ae1565d074b8805b28882e7b7581 /src/main/java/goodgenerator/blocks/tileEntity/base | |
| parent | d80fe13bf409ad11ffc8ddc34375c64be06da771 (diff) | |
| download | GT5-Unofficial-328376ff618b14aac4ba57d790066129c8ad95e8.tar.gz GT5-Unofficial-328376ff618b14aac4ba57d790066129c8ad95e8.tar.bz2 GT5-Unofficial-328376ff618b14aac4ba57d790066129c8ad95e8.zip | |
Implement generic processing logic (#176)
* Removed deprecated bartworks interface
* Migrated PrAss
* Migrated CoAL
* Migrated CoolantTower
* Migrated EHE
* Migrated compacts
* Migrated large turbine base
* Migrated UCFE
* Migrated FRF
* Migrated naq gen
* Migrated YOTTA
* Migrated LEG
* Migrated LES
* Migrated NA
* Updated deps
* Updated deps
* Derp
* Fixed PrAss in precise mode
* Added missing GPL getters in NA
* Fixed power of NA
* Enabled batch mode and void protection in FRF
* Addressed reviews
* Deleted LongPowerUsageBase in favor of ExtendedPowerMultiBlockBase
* Addressed reviews
* Limit recipe duration to 1 tick
* Updated dep
Diffstat (limited to 'src/main/java/goodgenerator/blocks/tileEntity/base')
4 files changed, 41 insertions, 199 deletions
diff --git a/src/main/java/goodgenerator/blocks/tileEntity/base/GT_MetaTileEntity_LargeTurbineBase.java b/src/main/java/goodgenerator/blocks/tileEntity/base/GT_MetaTileEntity_LargeTurbineBase.java index bb85923c5a..fe67924096 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/base/GT_MetaTileEntity_LargeTurbineBase.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/base/GT_MetaTileEntity_LargeTurbineBase.java @@ -19,6 +19,8 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -30,6 +32,8 @@ import gregtech.api.items.GT_MetaGenerated_Tool; 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.util.GT_Utility; import gregtech.common.items.GT_MetaGenerated_Tool_01; @@ -133,12 +137,14 @@ public abstract class GT_MetaTileEntity_LargeTurbineBase extends } @Override - public boolean checkRecipe(ItemStack aStack) { - if ((counter & 7) == 0 && (aStack == null || !(aStack.getItem() instanceof GT_MetaGenerated_Tool) - || aStack.getItemDamage() < 170 - || aStack.getItemDamage() > 179)) { + public @NotNull CheckRecipeResult checkProcessing() { + ItemStack controllerSlot = getControllerSlot(); + if ((counter & 7) == 0 + && (controllerSlot == null || !(controllerSlot.getItem() instanceof GT_MetaGenerated_Tool) + || controllerSlot.getItemDamage() < 170 + || controllerSlot.getItemDamage() > 179)) { stopMachine(); - return false; + return CheckRecipeResultRegistry.NO_TURBINE_FOUND; } ArrayList<FluidStack> tFluids = getStoredFluids(); if (tFluids.size() > 0) { @@ -148,16 +154,18 @@ public abstract class GT_MetaTileEntity_LargeTurbineBase extends || this.getBaseMetaTileEntity().hasInventoryBeenModified()) { counter = 0; baseEff = GT_Utility.safeInt( - (long) ((5F + ((GT_MetaGenerated_Tool) aStack.getItem()).getToolCombatDamage(aStack)) * 1000F)); + (long) ((5F + ((GT_MetaGenerated_Tool) controllerSlot.getItem()) + .getToolCombatDamage(controllerSlot)) * 1000F)); optFlow = GT_Utility.safeInt( (long) Math.max( Float.MIN_NORMAL, - ((GT_MetaGenerated_Tool) aStack.getItem()).getToolStats(aStack).getSpeedMultiplier() - * GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mToolSpeed + ((GT_MetaGenerated_Tool) controllerSlot.getItem()).getToolStats(controllerSlot) + .getSpeedMultiplier() + * GT_MetaGenerated_Tool.getPrimaryMaterial(controllerSlot).mToolSpeed * 50)); if (optFlow <= 0 || baseEff <= 0) { stopMachine(); // in case the turbine got removed - return false; + return CheckRecipeResultRegistry.NO_FUEL_FOUND; } } else { counter++; @@ -182,12 +190,12 @@ public abstract class GT_MetaTileEntity_LargeTurbineBase extends // stopMachine(); this.mEUt = 0; this.mEfficiency = 0; - return false; + return CheckRecipeResultRegistry.NO_FUEL_FOUND; } else { this.mMaxProgresstime = 1; this.mEfficiencyIncrease = 10; // Overvoltage is handled inside the MultiBlockBase when pushing out to dynamos. no need to do it here. - return true; + return CheckRecipeResultRegistry.GENERATING; } } diff --git a/src/main/java/goodgenerator/blocks/tileEntity/base/GT_MetaTileEntity_LongPowerUsageBase.java b/src/main/java/goodgenerator/blocks/tileEntity/base/GT_MetaTileEntity_LongPowerUsageBase.java deleted file mode 100644 index c36cfd7abc..0000000000 --- a/src/main/java/goodgenerator/blocks/tileEntity/base/GT_MetaTileEntity_LongPowerUsageBase.java +++ /dev/null @@ -1,174 +0,0 @@ -package goodgenerator.blocks.tileEntity.base; - -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.StatCollector; - -import com.github.bartimaeusnek.bartworks.util.BW_Util; -import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; - -import gregtech.api.metatileentity.implementations.*; -import gregtech.api.util.GT_Utility; - -/** - * Base class for multiblocks that supports TT energy hatches. - * - * @param <T> - */ -public abstract class GT_MetaTileEntity_LongPowerUsageBase<T extends GT_MetaTileEntity_LongPowerUsageBase<T>> - extends GT_MetaTileEntity_ExtendedPowerMultiBlockBase<T> { - - protected GT_MetaTileEntity_LongPowerUsageBase(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - protected GT_MetaTileEntity_LongPowerUsageBase(String aName) { - super(aName); - } - - @Override - public void clearHatches() { - mExoticEnergyHatches.clear(); - super.clearHatches(); - } - - @Override - public long getMaxInputVoltage() { - long rVoltage = 0; - for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { - if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { - rVoltage += tHatch.maxEUInput(); - } - } - for (GT_MetaTileEntity_Hatch tHatch : mExoticEnergyHatches) { - if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { - rVoltage += tHatch.maxEUInput(); - } - } - return rVoltage; - } - - @Override - public String[] getInfoData() { - return getInfoDataArray(this); - } - - protected long getRealVoltage() { - long rEnergy = 0; - if (mEnergyHatches.size() == 1 && mExoticEnergyHatches.isEmpty()) { - // it works like most of the gt multies - return mEnergyHatches.get(0).getBaseMetaTileEntity().getInputVoltage(); - } - for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { - if (isValidMetaTileEntity(tHatch)) { - rEnergy += tHatch.maxEUInput() * tHatch.maxAmperesIn(); - } - } - for (GT_MetaTileEntity_Hatch tHatch : mExoticEnergyHatches) { - if (isValidMetaTileEntity(tHatch)) { - rEnergy += tHatch.maxEUInput() * ((GT_MetaTileEntity_Hatch_EnergyMulti) tHatch).Amperes; - } - } - return rEnergy; - } - - @Override - public long getMaxInputAmps() { - long rAmps = 0; - for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { - if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { - rAmps += tHatch.maxAmperesIn(); - } - } - for (GT_MetaTileEntity_Hatch tHatch : mExoticEnergyHatches) { - if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { - rAmps += ((GT_MetaTileEntity_Hatch_EnergyMulti) tHatch).Amperes; - } - } - return rAmps; - } - - protected String[] getInfoDataArray(GT_MetaTileEntity_MultiBlockBase multiBlockBase) { - int mPollutionReduction = 0; - - for (GT_MetaTileEntity_Hatch_Muffler tHatch : this.mMufflerHatches) { - if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { - mPollutionReduction = Math.max(tHatch.calculatePollutionReduction(100), mPollutionReduction); - } - } - - long storedEnergy = 0; - long maxEnergy = 0; - - for (GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches) { - if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { - storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); - maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity(); - } - } - for (GT_MetaTileEntity_Hatch tHatch : this.mExoticEnergyHatches) { - if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { - storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); - maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity(); - } - } - - long nominalV = getRealVoltage(); - String tName = BW_Util.getTierNameFromVoltage(this.getMaxInputVoltage()); - if (tName.equals("MAX+")) tName = EnumChatFormatting.OBFUSCATED + "MAX+"; - - return new String[] { - StatCollector.translateToLocal("GT5U.multiblock.Progress") + ": " - + EnumChatFormatting.GREEN - + GT_Utility.formatNumbers(this.mProgresstime / 20) - + EnumChatFormatting.RESET - + " s / " - + EnumChatFormatting.YELLOW - + GT_Utility.formatNumbers(this.mMaxProgresstime / 20) - + EnumChatFormatting.RESET - + " s", - StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " - + EnumChatFormatting.GREEN - + GT_Utility.formatNumbers(storedEnergy) - + EnumChatFormatting.RESET - + " EU / " - + EnumChatFormatting.YELLOW - + GT_Utility.formatNumbers(maxEnergy) - + EnumChatFormatting.RESET - + " EU", - StatCollector.translateToLocal("GT5U.multiblock.usage") + ": " - + EnumChatFormatting.RED - + GT_Utility.formatNumbers(-this.lEUt) - + EnumChatFormatting.RESET - + " EU/t", - StatCollector.translateToLocal("GT5U.multiblock.mei") + ": " - + EnumChatFormatting.YELLOW - + GT_Utility.formatNumbers(this.getMaxInputVoltage()) - + EnumChatFormatting.RESET - + " EU/t(*" - + GT_Utility.formatNumbers(this.getMaxInputAmps()) - + "A) = " - + EnumChatFormatting.YELLOW - + GT_Utility.formatNumbers(nominalV) - + EnumChatFormatting.RESET, - StatCollector.translateToLocal("GT5U.machines.tier") + ": " - + EnumChatFormatting.YELLOW - + tName - + EnumChatFormatting.RESET, - StatCollector.translateToLocal("GT5U.multiblock.problems") + ": " - + EnumChatFormatting.RED - + (this.getIdealStatus() - this.getRepairStatus()) - + EnumChatFormatting.RESET - + " " - + StatCollector.translateToLocal("GT5U.multiblock.efficiency") - + ": " - + EnumChatFormatting.YELLOW - + (float) this.mEfficiency / 100.0F - + EnumChatFormatting.RESET - + " %", - StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " - + EnumChatFormatting.GREEN - + mPollutionReduction - + EnumChatFormatting.RESET - + " %" }; - } -} diff --git a/src/main/java/goodgenerator/blocks/tileEntity/base/LargeFusionComputer.java b/src/main/java/goodgenerator/blocks/tileEntity/base/LargeFusionComputer.java index 92f5144175..c997fd7bfd 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/base/LargeFusionComputer.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/base/LargeFusionComputer.java @@ -19,6 +19,8 @@ import net.minecraft.world.ChunkCoordIntPair; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; @@ -43,6 +45,8 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; import gregtech.api.objects.GT_ChunkManager; import gregtech.api.objects.GT_ItemStack; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_HatchElementBuilder; import gregtech.api.util.GT_Recipe; @@ -233,7 +237,7 @@ public abstract class LargeFusionComputer extends GT_MetaTileEntity_TooltipMulti if (mEfficiency < 0) mEfficiency = 0; if (mRunningOnLoad && checkMachine(aBaseMetaTileEntity, mInventory[1])) { this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); - checkRecipe(mInventory[1]); + checkRecipe(); } if (mUpdated) { mUpdate = 50; @@ -305,7 +309,7 @@ public abstract class LargeFusionComputer extends GT_MetaTileEntity_TooltipMulti mMaxProgresstime = 0; mEfficiencyIncrease = 0; this.mEUStore = (int) getBaseMetaTileEntity().getStoredEU(); - if (aBaseMetaTileEntity.isAllowedToWork()) checkRecipe(mInventory[1]); + if (aBaseMetaTileEntity.isAllowedToWork()) checkRecipe(); } } else { if (aTick % 100 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled() @@ -313,7 +317,7 @@ public abstract class LargeFusionComputer extends GT_MetaTileEntity_TooltipMulti turnCasingActive(mMaxProgresstime > 0); if (aBaseMetaTileEntity.isAllowedToWork()) { this.mEUStore = (int) getBaseMetaTileEntity().getStoredEU(); - if (checkRecipe(mInventory[1])) { + if (checkRecipe()) { if (this.mEUStore < this.mLastRecipe.mSpecialValue - this.mEUt) { mMaxProgresstime = 0; turnCasingActive(false); @@ -425,7 +429,7 @@ public abstract class LargeFusionComputer extends GT_MetaTileEntity_TooltipMulti } @Override - public boolean checkRecipe_EM(ItemStack aStack) { + public @NotNull CheckRecipeResult checkProcessing_EM() { ArrayList<FluidStack> tFluidList = getStoredFluids(); @@ -437,7 +441,7 @@ public abstract class LargeFusionComputer extends GT_MetaTileEntity_TooltipMulti if ((tRecipe == null && !mRunningOnLoad) || (tRecipe != null && (maxEUStore() < tRecipe.mSpecialValue))) { turnCasingActive(false); this.mLastRecipe = null; - return false; + return CheckRecipeResultRegistry.NO_RECIPE; } int pall = handleParallelRecipe( tRecipe, @@ -456,10 +460,10 @@ public abstract class LargeFusionComputer extends GT_MetaTileEntity_TooltipMulti this.mOutputFluids = getMultiOutput(mLastRecipe, pall).getKey().toArray(new FluidStack[0]); turnCasingActive(true); mRunningOnLoad = false; - return true; + return CheckRecipeResultRegistry.SUCCESSFUL; } } - return false; + return CheckRecipeResultRegistry.NO_RECIPE; } public long getMaxEUInput() { diff --git a/src/main/java/goodgenerator/blocks/tileEntity/base/LargeFusionComputerPP.java b/src/main/java/goodgenerator/blocks/tileEntity/base/LargeFusionComputerPP.java index c3adbe93ce..ecee690a74 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/base/LargeFusionComputerPP.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/base/LargeFusionComputerPP.java @@ -19,6 +19,8 @@ import net.minecraft.world.ChunkCoordIntPair; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; @@ -43,6 +45,8 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; import gregtech.api.objects.GT_ChunkManager; import gregtech.api.objects.GT_ItemStack; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.render.TextureFactory; import gregtech.api.util.AdvFusionPower; import gregtech.api.util.GT_HatchElementBuilder; @@ -232,7 +236,7 @@ public abstract class LargeFusionComputerPP extends GT_MetaTileEntity_TooltipMul if (mEfficiency < 0) mEfficiency = 0; if (mRunningOnLoad && checkMachine(aBaseMetaTileEntity, mInventory[1])) { this.mEUStore = aBaseMetaTileEntity.getStoredEU(); - checkRecipe(mInventory[1]); + checkRecipe(); } if (mUpdated) { mUpdate = 50; @@ -304,7 +308,7 @@ public abstract class LargeFusionComputerPP extends GT_MetaTileEntity_TooltipMul mMaxProgresstime = 0; mEfficiencyIncrease = 0; this.mEUStore = getBaseMetaTileEntity().getStoredEU(); - if (aBaseMetaTileEntity.isAllowedToWork()) checkRecipe(mInventory[1]); + if (aBaseMetaTileEntity.isAllowedToWork()) checkRecipe(); } } else { if (aTick % 100 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled() @@ -312,7 +316,7 @@ public abstract class LargeFusionComputerPP extends GT_MetaTileEntity_TooltipMul turnCasingActive(mMaxProgresstime > 0); if (aBaseMetaTileEntity.isAllowedToWork()) { this.mEUStore = getBaseMetaTileEntity().getStoredEU(); - if (checkRecipe(mInventory[1])) { + if (checkRecipe()) { if (this.mEUStore < this.mLastRecipe.mSpecialValue - this.mEUt) { mMaxProgresstime = 0; turnCasingActive(false); @@ -409,7 +413,7 @@ public abstract class LargeFusionComputerPP extends GT_MetaTileEntity_TooltipMul public abstract int extraPara(int startEnergy); @Override - public boolean checkRecipe_EM(ItemStack aStack) { + public @NotNull CheckRecipeResult checkProcessing_EM() { ArrayList<FluidStack> tFluidList = getStoredFluids(); if (tFluidList.size() > 1) { @@ -420,7 +424,7 @@ public abstract class LargeFusionComputerPP extends GT_MetaTileEntity_TooltipMul if ((tRecipe == null && !mRunningOnLoad) || (tRecipe != null && (maxEUStore() < tRecipe.mSpecialValue))) { turnCasingActive(false); this.mLastRecipe = null; - return false; + return CheckRecipeResultRegistry.NO_RECIPE; } int pall = handleParallelRecipe( tRecipe, @@ -439,10 +443,10 @@ public abstract class LargeFusionComputerPP extends GT_MetaTileEntity_TooltipMul this.mOutputFluids = getMultiOutput(mLastRecipe, pall).getKey().toArray(new FluidStack[0]); turnCasingActive(true); mRunningOnLoad = false; - return true; + return CheckRecipeResultRegistry.SUCCESSFUL; } } - return false; + return CheckRecipeResultRegistry.NO_RECIPE; } public long getMaxEUInput() { |
