diff options
Diffstat (limited to 'src')
16 files changed, 388 insertions, 1599 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java index d656e9840f..cf88fe51bb 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java @@ -61,6 +61,7 @@ import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; import com.github.bartimaeusnek.bartworks.system.material.processingLoaders.DownTierLoader; import com.github.bartimaeusnek.bartworks.system.oredict.OreDictHandler; +import com.github.bartimaeusnek.bartworks.util.ResultWrongSievert; import com.github.bartimaeusnek.bartworks.util.log.DebugLog; import cpw.mods.fml.common.FMLCommonHandler; @@ -75,6 +76,7 @@ import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.NetworkRegistry; import gregtech.api.GregTech_API; import gregtech.api.enums.Mods; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe; @@ -180,6 +182,8 @@ public final class MainMod { WerkstoffLoader.run(); LocalisationLoader.localiseAll(); + CheckRecipeResultRegistry.register(new ResultWrongSievert(0, ResultWrongSievert.NeededSievertType.EXACTLY)); + RadioHatchMaterialLoader.run(); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java index bb01ef8cce..b8a9bdecaa 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java @@ -21,7 +21,6 @@ import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockAn import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_Values.V; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE_GLOW; @@ -31,7 +30,6 @@ import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; -import java.util.List; import javax.annotation.Nullable; @@ -48,6 +46,8 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import com.github.bartimaeusnek.bartworks.API.SideReference; import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; @@ -60,6 +60,7 @@ import com.github.bartimaeusnek.bartworks.util.BW_Util; import com.github.bartimaeusnek.bartworks.util.BioCulture; import com.github.bartimaeusnek.bartworks.util.Coords; import com.github.bartimaeusnek.bartworks.util.MathUtils; +import com.github.bartimaeusnek.bartworks.util.ResultWrongSievert; import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; @@ -69,13 +70,15 @@ import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; 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_Input; 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_Recipe; -import gregtech.api.util.GT_Utility; public class GT_TileEntity_BioVat extends GT_MetaTileEntity_EnhancedMultiBlockBase<GT_TileEntity_BioVat> { @@ -86,7 +89,6 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_EnhancedMultiBlockBa private final HashSet<EntityPlayerMP> playerMPHashSet = new HashSet<>(); private final ArrayList<GT_MetaTileEntity_RadioHatch> mRadHatches = new ArrayList<>(); private int height = 1; - private GT_Recipe mLastRecipe; private Fluid mFluid = FluidRegistry.LAVA; private BioCulture mCulture; private ItemStack mStack; @@ -168,14 +170,6 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_EnhancedMultiBlockBa return ret; } - public boolean isLiquidInput(byte aSide) { - return false; - } - - public boolean isLiquidOutput(byte aSide) { - return false; - } - private int getInputCapacity() { return this.mInputHatches.stream().mapToInt(GT_MetaTileEntity_Hatch_Input::getCapacity).sum(); } @@ -230,115 +224,60 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_EnhancedMultiBlockBa return MathUtils.clamp(1, ret, ConfigHandler.bioVatMaxParallelBonus); } - private List<ItemStack> getItemInputs() { - ArrayList<ItemStack> tInputList = this.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; + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) { + if (!BW_Util.areStacksEqualOrNull((ItemStack) recipe.mSpecialItems, getControllerSlot())) + return CheckRecipeResultRegistry.NO_RECIPE; + int[] conditions = GT_TileEntity_BioVat.specialValueUnpack(recipe.mSpecialValue); + mNeededSievert = conditions[3]; + + if (mGlassTier < conditions[0]) { + return CheckRecipeResultRegistry.insufficientMachineTier(conditions[0]); + } + + if (conditions[2] == 0) { + if (mSievert < mNeededSievert) { + return ResultWrongSievert.insufficientSievert(mNeededSievert); + } + } else { + if (mSievert != conditions[3]) { + return ResultWrongSievert.wrongSievert(conditions[3]); } } + + return CheckRecipeResultRegistry.SUCCESSFUL; } - } - return tInputList; - } - - private List<FluidStack> getFluidInputs() { - ArrayList<FluidStack> tFluidList = this.getStoredFluids(); - int tFluidList_sS = tFluidList.size(); - for (int i = 0; i < tFluidList_sS - 1; i++) { - for (int j = i + 1; j < tFluidList_sS; j++) { - if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { - tFluidList.remove(j--); - tFluidList_sS = tFluidList.size(); - } else { - tFluidList.remove(i--); - tFluidList_sS = tFluidList.size(); - break; + + @NotNull + @Override + public CheckRecipeResult process() { + CheckRecipeResult result = super.process(); + if (!result.wasSuccessful()) { + return result; + } + // We already made sure the recipe runs. Now the vat looks for as many "parallels" as it can do + mExpectedMultiplier = getExpectedMultiplier(lastRecipe.getFluidOutput(0), true); + mTimes = 1; + for (int i = 1; i < mExpectedMultiplier; i++) { + if (depleteInput(lastRecipe.mFluidInputs[0])) { + mTimes++; } } + this.outputFluids[0].amount *= mTimes; + return result; } - } - return tFluidList; + }; } @Override - public boolean checkRecipe(ItemStack itemStack) { - GT_Recipe.GT_Recipe_Map gtRecipeMap = this.getRecipeMap(); - - if (gtRecipeMap == null) return false; - - ItemStack[] tInputs = getItemInputs().toArray(new ItemStack[0]); - FluidStack[] tFluids = getFluidInputs().toArray(new FluidStack[0]); - - if (tFluids.length <= 0) return false; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = V[tTier]; - - GT_Recipe gtRecipe = gtRecipeMap.findRecipe( - this.getBaseMetaTileEntity(), - this.mLastRecipe, - false, - tEnergy, - tFluids, - itemStack, - tInputs); - - if (gtRecipe == null) return false; - - assert gtRecipe.mFluidInputs.length == 1; - assert gtRecipe.mFluidOutputs.length == 1; - - if (!BW_Util.areStacksEqualOrNull((ItemStack) gtRecipe.mSpecialItems, itemStack)) return false; - - int[] conditions = GT_TileEntity_BioVat.specialValueUnpack(gtRecipe.mSpecialValue); - - this.mNeededSievert = conditions[3]; - - if (conditions[2] == 0 ? (this.mSievert < this.mNeededSievert || this.mGlassTier < conditions[0]) - : (this.mSievert != conditions[3] || this.mGlassTier < conditions[0])) - return false; - - this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - if (!canOutputAll(gtRecipe)) return false; - if (!gtRecipe.isRecipeInputEqual(true, tFluids, tInputs)) return false; - - final FluidStack recipeFluidOutput = gtRecipe.getFluidOutput(0); - final FluidStack recipeFluidInput = gtRecipe.mFluidInputs[0]; - - this.mExpectedMultiplier = this.getExpectedMultiplier(recipeFluidOutput, true); - - this.mTimes = 1; - for (int i = 1; i < this.mExpectedMultiplier; i++) { - if (this.depleteInput(recipeFluidInput)) { - this.mTimes++; - } - } - - this.mOutputFluids = new FluidStack[] { - new FluidStack(recipeFluidOutput, recipeFluidOutput.amount * this.mTimes) }; - - BW_Util.calculateOverclockedNessMulti(gtRecipe.mEUt, gtRecipe.mDuration, 1, tEnergy, this); - - if (this.mEUt > 0) this.mEUt = -this.mEUt; - this.mProgresstime = 0; - - if (gtRecipe.mCanBeBuffered) this.mLastRecipe = gtRecipe; - - this.updateSlots(); - return true; + protected void setupProcessingLogic(ProcessingLogic logic) { + super.setupProcessingLogic(logic); + logic.setSpecialSlotItem(getControllerSlot()); } public FluidStack getStoredFluidOutputs() { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java index c64ae704ca..e46199d654 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java @@ -30,8 +30,6 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; import java.util.List; import net.minecraft.entity.player.EntityPlayerMP; @@ -43,11 +41,12 @@ import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import org.jetbrains.annotations.NotNull; + import com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration.BW_Meta_Items; import com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration.CircuitImprintLoader; import com.github.bartimaeusnek.bartworks.util.BWRecipes; import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; -import com.github.bartimaeusnek.bartworks.util.BW_Util; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; @@ -57,14 +56,18 @@ import com.gtnewhorizons.modularui.api.screen.UIBuildContext; import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; import gregtech.api.GregTech_API; +import gregtech.api.enums.SoundResource; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; 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; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; @@ -82,6 +85,7 @@ public class GT_TileEntity_CircuitAssemblyLine extends private static final String STRUCTURE_PIECE_NEXT = "next"; private String imprintedItemName; + private ItemStack imprintedStack; private static final IStructureDefinition<GT_TileEntity_CircuitAssemblyLine> STRUCTURE_DEFINITION = StructureDefinition .<GT_TileEntity_CircuitAssemblyLine>builder() @@ -148,7 +152,6 @@ public class GT_TileEntity_CircuitAssemblyLine extends } private NBTTagCompound type = new NBTTagCompound(); - private GT_Recipe bufferedRecipe; public GT_TileEntity_CircuitAssemblyLine(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -204,64 +207,38 @@ public class GT_TileEntity_CircuitAssemblyLine extends super.saveNBTData(aNBT); } - private final Collection<GT_Recipe> GT_RECIPE_COLLECTION = new HashSet<>(); - @Override - public boolean checkRecipe(ItemStack itemStack) { - if (this.type.equals(new NBTTagCompound())) if (!this.imprintMachine(itemStack)) return false; - - if (this.bufferedRecipe != null && this.bufferedRecipe.isRecipeInputEqual( - true, - false, - BW_Util.getFluidsFromInputHatches(this), - getStoredInputs().toArray(new ItemStack[0]))) { - setRecipeStats(); - return true; - } - - ItemStack stack = ItemStack.loadItemStackFromNBT(this.type); - imprintedItemName = GT_LanguageManager.getTranslateableItemStackName(stack); + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return BWRecipes.instance.getMappingsFor((byte) 3); + } - if (stack == null) return false; + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().enablePerfectOverclock(); + } - if (this.GT_RECIPE_COLLECTION.isEmpty()) { - for (GT_Recipe recipe : BWRecipes.instance.getMappingsFor((byte) 3).mRecipeList) { - if (GT_Utility.areStacksEqual(recipe.mOutputs[0], stack, true)) { - this.GT_RECIPE_COLLECTION.add(recipe); - } - } + @NotNull + @Override + public CheckRecipeResult checkProcessing() { + if (this.type.equals(new NBTTagCompound()) && !this.imprintMachine(getControllerSlot())) + return SimpleCheckRecipeResult.ofFailure("no_imprint"); + if (imprintedItemName == null || imprintedStack == null) { + imprintedStack = new ItemStack(BW_Meta_Items.getNEWCIRCUITS(), 1, 0); + imprintedStack.setTagCompound(type); + imprintedItemName = GT_LanguageManager.getTranslateableItemStackName(imprintedStack); } + return super.checkProcessing(); + } - for (GT_Recipe recipe : this.GT_RECIPE_COLLECTION) { - if (!canOutputAll(recipe)) return false; - if (recipe.isRecipeInputEqual( - true, - false, - BW_Util.getFluidsFromInputHatches(this), - getStoredInputs().toArray(new ItemStack[0]))) - this.bufferedRecipe = recipe; - else continue; - - this.setRecipeStats(); - return true; - } - return false; + @Override + protected void setupProcessingLogic(ProcessingLogic logic) { + super.setupProcessingLogic(logic); + logic.setSpecialSlotItem(imprintedStack); } - private void setRecipeStats() { - calculatePerfectOverclockedNessMulti( - this.bufferedRecipe.mEUt, - this.bufferedRecipe.mDuration, - 1, - this.getMaxInputVoltage()); - if (this.mEUt > 0) this.mEUt = -this.mEUt; - this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = this.bufferedRecipe.mOutputs; - this.mOutputFluids = this.bufferedRecipe.mFluidOutputs; - sendLoopStart((byte) 20); - this.updateSlots(); + @Override + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_MAGNETIZER_LOOP; } @Override @@ -445,6 +422,11 @@ public class GT_TileEntity_CircuitAssemblyLine extends } @Override + public boolean supportsBatchMode() { + return true; + } + + @Override public boolean isRecipeLockingEnabled() { return imprintedItemName != null && !imprintedItemName.equals(""); } @@ -466,7 +448,6 @@ public class GT_TileEntity_CircuitAssemblyLine extends int z) { super.getWailaNBTData(player, tile, tag, world, x, y, z); String imprintedWith = getTypeForDisplay(); - if (imprintedWith != "") tag.setString("ImprintedWith", imprintedWith); - + if (!imprintedWith.isEmpty()) tag.setString("ImprintedWith", imprintedWith); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CrackingDistillTower.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CrackingDistillTower.java deleted file mode 100644 index 2f14088a3d..0000000000 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CrackingDistillTower.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following - * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial - * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -package com.github.bartimaeusnek.bartworks.common.tileentities.multis; - -import java.util.ArrayList; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -import com.github.bartimaeusnek.bartworks.util.BWRecipes; -import com.github.bartimaeusnek.bartworks.util.BW_Util; -import com.github.bartimaeusnek.bartworks.util.MathUtils; - -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_DistillationTower; - -public class GT_TileEntity_CrackingDistillTower extends GT_MetaTileEntity_DistillationTower { - - public GT_TileEntity_CrackingDistillTower(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GT_TileEntity_CrackingDistillTower(String aName) { - super(aName); - } - - @Override - public boolean checkRecipe(ItemStack itemStack) { - if (!GT_Utility.areStacksEqual(itemStack, GT_Utility.getIntegratedCircuit(0), true)) return false; - else { - FluidStack[] array = new FluidStack[0]; - ArrayList<FluidStack> fluidInputs = new ArrayList<>(); - for (GT_MetaTileEntity_Hatch_Input hatch : this.mInputHatches) { - if (hatch != null) { - fluidInputs.add(hatch.getFluid()); - } - } - array = fluidInputs.toArray(array); - GT_Recipe.GT_Recipe_Map rMapCracking = GT_Recipe.GT_Recipe_Map.sCrakingRecipes; - GT_Recipe.GT_Recipe_Map rMapDistillTower = GT_Recipe.GT_Recipe_Map.sDistillationRecipes; - GT_Recipe recipeCracking = rMapCracking - .findRecipe(this.getBaseMetaTileEntity(), false, this.getMaxInputVoltage(), array, itemStack); - if (recipeCracking == null) return false; - GT_Recipe recipeDistill = rMapDistillTower.findRecipe( - this.getBaseMetaTileEntity(), - false, - this.getMaxInputVoltage(), - recipeCracking.mFluidOutputs); - if (recipeDistill == null) return false; - float ratio = (float) recipeCracking.mFluidOutputs[0].amount / (float) recipeDistill.mFluidInputs[0].amount; - FluidStack[] nuoutputs = new FluidStack[recipeDistill.mFluidOutputs.length]; - for (int i = 0; i < nuoutputs.length; i++) { - nuoutputs[i] = recipeDistill.mFluidOutputs[i]; - nuoutputs[i].amount = MathUtils.floorInt(recipeDistill.mFluidOutputs[i].amount * ratio); - } - BWRecipes.DynamicGTRecipe combined = new BWRecipes.DynamicGTRecipe( - true, - null, - recipeDistill.mOutputs, - null, - recipeDistill.mChances, - recipeCracking.mFluidInputs, - nuoutputs, - (MathUtils.floorInt(recipeDistill.mDuration * ratio)) + recipeCracking.mDuration, - Math.max((MathUtils.floorInt(recipeDistill.mEUt * ratio)), recipeCracking.mEUt), - 0); - if (combined.isRecipeInputEqual(true, array)) { - this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - BW_Util.calculateOverclockedNessMulti( - combined.mEUt, - combined.mDuration, - 1, - this.getMaxInputVoltage(), - this); - if (this.mMaxProgresstime == Integer.MAX_VALUE - 1 && this.mEUt == Integer.MAX_VALUE - 1) return false; - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputFluids = combined.mFluidOutputs.clone(); - this.mOutputItems = combined.mOutputs.clone(); - this.updateSlots(); - return true; - } - } - return false; - } -} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java index b09d512fff..2466ff6c53 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java @@ -18,7 +18,6 @@ import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.MULTI import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.TT; import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; import static gregtech.api.enums.GT_HatchElement.*; -import static gregtech.api.enums.GT_Values.V; import static gregtech.api.enums.Textures.BlockIcons.*; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; @@ -27,16 +26,14 @@ import java.util.List; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ChunkCoordinates; -import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.NotNull; import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.client.renderer.BW_EICPistonVisualizer; @@ -64,6 +61,7 @@ import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_ExtendedPowerMultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.render.TextureFactory; @@ -138,9 +136,7 @@ public class GT_TileEntity_ElectricImplosionCompressor if (te.piston) { Block candidate = world.getBlock(x, y, z); int candidateMeta = world.getBlockMetadata(x, y, z); - if (getTierOfBlock(candidate, candidateMeta) == -1) { - return false; - } + return getTierOfBlock(candidate, candidateMeta) != -1; } return true; } @@ -190,7 +186,6 @@ public class GT_TileEntity_ElectricImplosionCompressor add(Pair.of(GregTech_API.sBlockMetal9, 8)); } - ; }; } @@ -260,67 +255,31 @@ public class GT_TileEntity_ElectricImplosionCompressor } @Override - public boolean checkRecipe(ItemStack aStack) { - lEUt = 0; - mOutputItems = null; - mOutputFluids = null; - long tTotalEU = getMaxInputEu(); - - // Only allow up to one tier skip - byte tTier = (byte) (mMaxHatchTier + 1); - - ItemStack[] tItemInputs = getStoredInputs().toArray(new ItemStack[0]); - FluidStack[] tFluidInputs = getStoredFluids().toArray(new FluidStack[0]); - - if ((tItemInputs.length > 0) || (tFluidInputs.length > 0)) { - GT_Recipe tRecipe = eicMap.findRecipe(getBaseMetaTileEntity(), false, V[tTier], tFluidInputs, tItemInputs); - if (tRecipe == null) { - return false; - } - - int tCurrentMaxParallel = 1; - if (mBlockTier > 1) { - tCurrentMaxParallel = (int) Math.pow(4, Math.max(mBlockTier - 1, 0)); - } - - GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(tRecipe).setItemInputs(tItemInputs) - .setFluidInputs(tFluidInputs).setAvailableEUt(tTotalEU).setMaxParallel(tCurrentMaxParallel) - .enableConsumption().enableOutputCalculation().setController(this); - - if (batchMode) { - helper.enableBatchMode(128); - } - - helper.build(); - - if (helper.getCurrentParallel() == 0) { - return false; - } - - GT_OverclockCalculator calculator = new GT_OverclockCalculator().setRecipeEUt(tRecipe.mEUt).setEUt(tTotalEU) - .setDuration(tRecipe.mDuration) - .setParallel((int) Math.floor(helper.getCurrentParallel() / helper.getDurationMultiplier())) - .calculate(); - - lEUt = -calculator.getConsumption(); - mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplier()); - - this.mEfficiency = 10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000; - this.mEfficiencyIncrease = 10000; + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return eicMap; + } - // In case recipe is too OP for that machine - if (mMaxProgresstime == Integer.MAX_VALUE - 1 && lEUt == Long.MAX_VALUE - 1) return false; - if (this.lEUt > 0) { - this.lEUt = -this.lEUt; + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected GT_OverclockCalculator createOverclockCalculator(@NotNull GT_Recipe recipe, + @NotNull GT_ParallelHelper helper) { + // For overclocking we'll allow all power to be used + return super.createOverclockCalculator(recipe, helper).setEUt(getMaxInputEu()).setAmperage(1); } + }.setMaxParallelSupplier(() -> (int) Math.pow(4, Math.max(mBlockTier - 1, 0))); + } - this.mOutputItems = helper.getItemOutputs(); - this.mOutputFluids = helper.getFluidOutputs(); - - this.updateSlots(); - return true; - } - return false; + @Override + protected void setProcessingLogicPower(ProcessingLogic logic) { + long amperage = getMaxInputAmps(); + long voltage = getAverageInputVoltage(); + // We allow one OC, if there is enough amperage, no matter which type of hatch is used + logic.setAvailableVoltage(amperage >= 4 ? voltage * 4 : voltage); + logic.setAvailableAmperage(amperage >= 4 ? amperage / 4 : amperage); } private void updateChunkCoordinates() { @@ -520,21 +479,6 @@ public class GT_TileEntity_ElectricImplosionCompressor return survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 1, 6, 0, elementBudget, env, false, true); } - public boolean onWireCutterRightClick(ForgeDirection side, byte aWrenchingSide, EntityPlayer aPlayer, float aX, - float aY, float aZ) { - if (aPlayer.isSneaking()) { - batchMode = !batchMode; - if (batchMode) { - GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); - } else { - GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); - } - return true; - } - - return false; - } - @Override public boolean supportsBatchMode() { return true; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java index 3003a1141b..4ef6a5f7d1 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java +++ b/src/main/java/com/github/bart |
