diff --git a/src/main/java/gregtech/api/capability/impl/AbstractRecipeLogic.java b/src/main/java/gregtech/api/capability/impl/AbstractRecipeLogic.java index 7482f3a9ac6..75d24b74a4c 100644 --- a/src/main/java/gregtech/api/capability/impl/AbstractRecipeLogic.java +++ b/src/main/java/gregtech/api/capability/impl/AbstractRecipeLogic.java @@ -18,13 +18,14 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.network.PacketBuffer; import net.minecraft.util.NonNullList; -import net.minecraft.world.*; +import net.minecraft.world.World; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.Constants; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidTank; import net.minecraftforge.items.IItemHandlerModifiable; +import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -35,10 +36,14 @@ public abstract class AbstractRecipeLogic extends MTETrait implements IWorkable, private static final String ALLOW_OVERCLOCKING = "AllowOverclocking"; private static final String OVERCLOCK_VOLTAGE = "OverclockVoltage"; - public final RecipeMap recipeMap; + public static final double STANDARD_OVERCLOCK_VOLTAGE_MULTIPLIER = 4.0; + public static final double STANDARD_OVERCLOCK_DURATION_DIVISOR = ConfigHolder.U.overclockDivisor; + public static final double PERFECT_OVERCLOCK_DURATION_DIVISOR = 4.0; + + private final RecipeMap recipeMap; protected Recipe previousRecipe; - protected boolean allowOverclocking = true; + private boolean allowOverclocking = true; protected int parallelRecipesPerformed; private long overclockVoltage = 0; private LongSupplier overclockPolicy = this::getMaxVoltage; @@ -59,6 +64,12 @@ public abstract class AbstractRecipeLogic extends MTETrait implements IWorkable, protected boolean hasPerfectOC = false; + /** + * DO NOT use the parallelLimit field directly, EVER + * use {@link AbstractRecipeLogic#setParallelLimit(int)} instead + */ + private int parallelLimit = 1; + public AbstractRecipeLogic(MetaTileEntity tileEntity, RecipeMap recipeMap) { super(tileEntity); this.recipeMap = recipeMap; @@ -78,7 +89,7 @@ public AbstractRecipeLogic(MetaTileEntity tileEntity, RecipeMap recipeMap, bo protected abstract boolean drawEnergy(int recipeEUt); - protected abstract long getMaxVoltage(); + abstract long getMaxVoltage(); protected IItemHandlerModifiable getInputInventory() { return metaTileEntity.getImportItems(); @@ -138,6 +149,14 @@ public void update() { } } + /** + * DO NOT use the recipeMap field directly, EVER + * @return the current RecipeMap of the logic + */ + public RecipeMap getRecipeMap() { + return this.recipeMap; + } + protected boolean shouldSearchForRecipes() { return canWorkWithInputs() && canFitNewOutputs(); } @@ -214,11 +233,9 @@ protected void trySearchNewRecipe() { Recipe currentRecipe; IItemHandlerModifiable importInventory = getInputInventory(); IMultipleTankHandler importFluids = getInputTank(); - IItemHandlerModifiable exportInventory = getOutputInventory(); - IMultipleTankHandler exportFluids = getOutputTank(); // see if the last recipe we used still works - if (this.previousRecipe != null && this.previousRecipe.matches(false, importInventory, importFluids)) + if (checkPreviousRecipe()) currentRecipe = this.previousRecipe; // If there is no active recipe, then we need to find one. else { @@ -231,31 +248,79 @@ protected void trySearchNewRecipe() { this.invalidInputsForRecipes = (currentRecipe == null); // proceed if we have a usable recipe. - if (currentRecipe != null) { - - currentRecipe = findParallelRecipe( - this, - currentRecipe, - importInventory, - importFluids, - exportInventory, - exportFluids, - maxVoltage, metaTileEntity.getParallelLimit()); - - if (currentRecipe != null && setupAndConsumeRecipeInputs(currentRecipe, importInventory)) { - setupRecipe(currentRecipe); - } + if (currentRecipe != null && checkRecipe(currentRecipe)) { + prepareRecipe(currentRecipe); } // Inputs have been inspected. metaTileEntity.getNotifiedItemInputList().clear(); metaTileEntity.getNotifiedFluidInputList().clear(); } + /** + * + * @return true if the previous recipe is valid and can be run again + */ + protected boolean checkPreviousRecipe() { + return this.previousRecipe != null && this.previousRecipe.matches(false, getInputInventory(), getInputTank()); + } + + /** + * checks the recipe before preparing it + * @param recipe the recipe to check + * @return true if the recipe is allowed to be used, else false + */ + protected boolean checkRecipe(Recipe recipe) { + return true; + } + + /** + * prepares the recipe to be run + * + * the recipe is attempted to be run in parallel + * the potentially parallel recipe is then checked to exist + * if it exists, it is checked whether the recipe is able to be run with the current inputs + * + * if the above conditions are met, the recipe is engaged to be run + * + * @param recipe the recipe to prepare + * + * @return true if the recipe was successfully prepared, else false + */ + protected boolean prepareRecipe(Recipe recipe) { + recipe = findParallelRecipe( + this, + recipe, + getInputInventory(), + getInputTank(), + getOutputInventory(), + getOutputTank(), + getMaxVoltage(), getParallelLimit()); + + if (recipe != null && setupAndConsumeRecipeInputs(recipe, getInputInventory())) { + setupRecipe(recipe); + return true; + } + return false; + } + + + /** + * DO NOT use the parallelLimit field directly, EVER + * @return the current parallel limit of the logic + */ + public int getParallelLimit() { + return parallelLimit; + } + + public void setParallelLimit(int amount) { + parallelLimit = amount; + } + public Enum getParallelLogicType() { return ParallelLogicType.MULTIPLY; } - protected int getMinTankCapacity(IMultipleTankHandler tanks) { + protected int getMinTankCapacity(@Nonnull IMultipleTankHandler tanks) { if (tanks.getTanks() == 0) { return 0; } @@ -267,7 +332,7 @@ protected int getMinTankCapacity(IMultipleTankHandler tanks) { } protected Recipe findRecipe(long maxVoltage, IItemHandlerModifiable inputs, IMultipleTankHandler fluidInputs, MatchingMode mode) { - return recipeMap.findRecipe(maxVoltage, inputs, fluidInputs, getMinTankCapacity(getOutputTank()), mode); + return getRecipeMap().findRecipe(maxVoltage, inputs, fluidInputs, getMinTankCapacity(getOutputTank()), mode); } protected static boolean areItemStacksEqual(ItemStack stackA, ItemStack stackB) { @@ -291,7 +356,7 @@ protected static boolean areItemStacksEqual(ItemStack stackA, ItemStack stackB) protected boolean setupAndConsumeRecipeInputs(Recipe recipe, IItemHandlerModifiable importInventory) { //Format: EU/t, Duration - int[] resultOverclock = calculateOverclock(recipe.getEUt(), this.overclockPolicy.getAsLong(), recipe.getDuration()); + int[] resultOverclock = calculateOverclock(recipe); int totalEUt = resultOverclock[0] * resultOverclock[1]; IItemHandlerModifiable exportInventory = getOutputInventory(); @@ -330,42 +395,125 @@ protected boolean setupAndConsumeRecipeInputs(Recipe recipe, IItemHandlerModifia return recipe.matches(true, importInventory, importFluids); } - protected int[] calculateOverclock(int EUt, long voltage, int duration) { - if (!allowOverclocking) { - return new int[]{EUt, duration}; - } - boolean negativeEU = EUt < 0; - int tier = getOverclockingTier(voltage); + /** + * calculates the overclocked EUt and duration + * @param recipe the recipe to run + * @return an int array of {OverclockedEUt, OverclockedDuration} + */ + protected int[] calculateOverclock(@Nonnull Recipe recipe) { + int recipeEUt = recipe.getEUt(); + int recipeDuration = recipe.getDuration(); + // Cannot overclock, keep recipe the same + if (!checkCanOverclock(recipeEUt)) + return new int[]{recipeEUt, recipeDuration}; - // Cannot overclock - if (GTValues.V[tier] <= EUt || tier == 0) - return new int[]{EUt, duration}; + // invert EU for overclocking calculations (so it increases in the positive direction) + boolean negativeEU = recipeEUt < 0; + // perform the actual overclocking + int[] overclockResult = performOverclocking(recipe, negativeEU); + + // make the EU negative after it has been made further away from 0 if (negativeEU) - EUt = -EUt; + overclockResult[0] *= -1; - int resultEUt = EUt; - double resultDuration = duration; - double divisor = hasPerfectOC ? 4.0 : ConfigHolder.U.overclockDivisor; - int maxOverclocks = tier - 1; // exclude ULV overclocking + return overclockResult; + } - //do not overclock further if duration is already too small - while (resultDuration >= 3 && resultEUt <= GTValues.V[tier - 1] && maxOverclocks != 0) { - resultEUt *= 4; - resultDuration /= divisor; + /** + * + * @param recipeEUt the EU/t of the recipe attempted to be run + * @return true if the recipe is able to overclock, else false + */ + protected boolean checkCanOverclock(int recipeEUt) { + if (!isAllowOverclocking()) + return false; + + // check if the voltage to run at is higher than the recipe, and that it is not ULV tier + int tier = getOverclockingTier(getMaxVoltage()); + return tier != 0 && tier > GTUtility.getTierByVoltage(recipeEUt); + } + + /** + * performs the actual overclocking of voltage and duration + * + * @param recipe the recipe to overclock + * @return an int array of {OverclockedEUt, OverclockedDuration} + */ + protected int[] performOverclocking(Recipe recipe, boolean negativeEU) { + int maxOverclocks = getOverclockingTier(getMaxVoltage()) - 1; // exclude ULV overclocking + + return runOverclockingLogic(recipe, negativeEU, maxOverclocks); + } + + /** + * actually runs the overclocking logic + * @param recipe the recipe to overclock + * @param maxOverclocks the maximum amount of overclocks to perform + * @return an int array of {OverclockedEUt, OverclockedDuration} + */ + protected int[] runOverclockingLogic(@Nonnull Recipe recipe, boolean negativeEU, int maxOverclocks) { + return standardOverclockingLogic(recipe.getEUt() * (negativeEU ? -1 : 1), + getMaxVoltage(), + recipe.getDuration(), + getOverclockingDurationDivisor(), + getOverclockingVoltageMultiplier(), + maxOverclocks + ); + } + + /** + * + * @return the divisor to use for reducing duration upon overclocking + */ + protected double getOverclockingDurationDivisor() { + return hasPerfectOC ? PERFECT_OVERCLOCK_DURATION_DIVISOR : STANDARD_OVERCLOCK_DURATION_DIVISOR; + } + + /** + * + * @return the multiplier to use for increasing voltage upon overclocking + */ + protected double getOverclockingVoltageMultiplier() { + return STANDARD_OVERCLOCK_VOLTAGE_MULTIPLIER; + } + + /** + * applies standard logic for overclocking, where each overclock modifies energy and duration + * + * @param recipeEUt the EU/t of the recipe to overclock + * @param maximumVoltage the maximum voltage the recipe is allowed to be run at + * @param recipeDuration the duration of the recipe to overclock + * @param durationDivisor the value to divide the duration by for each overclock + * @param voltageMultiplier the value to multiply the voltage by for each overclock + * @param maxOverclocks the maximum amount of overclocks allowed + * @return an int array of {OverclockedEUt, OverclockedDuration} + */ + protected static int[] standardOverclockingLogic(int recipeEUt, long maximumVoltage, int recipeDuration, double durationDivisor, double voltageMultiplier, int maxOverclocks) { + int overclockedEUt = recipeEUt; + double overclockedDuration = recipeDuration; + + while (overclockedEUt * voltageMultiplier <= GTValues.V[GTUtility.getTierByVoltage(maximumVoltage)] && overclockedDuration / durationDivisor > 0 && maxOverclocks > 0) { + overclockedEUt *= voltageMultiplier; + overclockedDuration /= durationDivisor; maxOverclocks--; } - return new int[]{negativeEU ? -resultEUt : resultEUt, (int) Math.ceil(resultDuration)}; + return new int[]{overclockedEUt, (int) Math.ceil(overclockedDuration)}; } + /** + * + * @param voltage the maximum voltage the recipe is allowed to run at + * @return the highest voltage tier the machine should use to overclock with + */ protected int getOverclockingTier(long voltage) { return GTUtility.getTierByVoltage(voltage); } - protected long getVoltageByTier(final int tier) { - return GTValues.V[tier]; - } - + /** + * + * @return a String array of the voltage names allowed to be used for overclocking + */ public String[] getAvailableOverclockingTiers() { final int maxTier = getOverclockingTier(getMaxVoltage()); final String[] result = new String[maxTier + 1]; @@ -374,14 +522,17 @@ public String[] getAvailableOverclockingTiers() { return result; } + /** + * sets up the recipe to be run + * @param recipe the recipe to run + */ protected void setupRecipe(Recipe recipe) { - int[] resultOverclock = calculateOverclock(recipe.getEUt(), this.overclockPolicy.getAsLong(), recipe.getDuration()); + int[] resultOverclock = calculateOverclock(recipe); this.progressTime = 1; setMaxProgress(resultOverclock[1]); this.recipeEUt = resultOverclock[0]; this.fluidOutputs = GTUtility.copyFluidList(recipe.getFluidOutputs()); - int tier = getMachineTierForRecipe(recipe); - this.itemOutputs = GTUtility.copyStackList(recipe.getResultItemOutputs(getOutputInventory().getSlots(), random, tier)); + this.itemOutputs = GTUtility.copyStackList(recipe.getResultItemOutputs(getOutputInventory().getSlots(), random, GTUtility.getTierByVoltage(recipeEUt))); if (this.wasActiveAndNeedsUpdate) { this.wasActiveAndNeedsUpdate = false; } else { @@ -389,10 +540,9 @@ protected void setupRecipe(Recipe recipe) { } } - protected int getMachineTierForRecipe(Recipe recipe) { - return GTUtility.getTierByVoltage(getMaxVoltage()); - } - + /** + * completes the recipe which was being run, and performs actions done upon recipe completion + */ protected void completeRecipe() { MetaTileEntity.addItemsToItemHandler(getOutputInventory(), false, itemOutputs); MetaTileEntity.addFluidsToFluidHandler(getOutputTank(), false, fluidOutputs); @@ -410,10 +560,6 @@ public double getProgressPercent() { return getMaxProgress() == 0 ? 0.0 : getProgress() / (getMaxProgress() * 1.0); } - public int getTicksTimeLeft() { - return maxProgressTime == 0 ? 0 : (maxProgressTime - progressTime); - } - @Override public int getProgress() { return progressTime; @@ -428,6 +574,10 @@ public int getRecipeEUt() { return recipeEUt; } + /** + * sets the amount of ticks of running time to finish the recipe + * @param maxProgress the amount of ticks to set + */ public void setMaxProgress(int maxProgress) { this.maxProgressTime = maxProgress; metaTileEntity.markDirty(); @@ -493,7 +643,6 @@ public void setOverclockVoltage(final long overclockVoltage) { * The actual value will come from the saved tag when the tile is loaded for pre-existing machines. *

* NOTE: This should only be used directly after construction of the workable. - * Use setOverclockVoltage() or setOverclockTier() for a more dynamic use case. */ public void enableOverclockVoltage() { setOverclockVoltage(getMaxVoltage()); @@ -511,7 +660,7 @@ public void setOverclockTier(final int tier) { setOverclockVoltage(0); return; } - setOverclockVoltage(getVoltageByTier(tier)); + setOverclockVoltage(GTValues.V[tier]); } @Override diff --git a/src/main/java/gregtech/api/capability/impl/MultiblockRecipeLogic.java b/src/main/java/gregtech/api/capability/impl/MultiblockRecipeLogic.java index a39e17386ad..04af24e7007 100644 --- a/src/main/java/gregtech/api/capability/impl/MultiblockRecipeLogic.java +++ b/src/main/java/gregtech/api/capability/impl/MultiblockRecipeLogic.java @@ -10,6 +10,7 @@ import gregtech.api.recipes.Recipe; import net.minecraftforge.items.IItemHandlerModifiable; +import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.List; @@ -102,7 +103,7 @@ protected void trySearchNewRecipe() { return; } - // Distinct buses only apply to some of the multiblocks, so check the controller against a lower class + // Distinct buses only apply to some multiblocks, so check the controller against a lower class if (controller instanceof RecipeMapMultiblockController) { RecipeMapMultiblockController distinctController = (RecipeMapMultiblockController) controller; @@ -143,7 +144,7 @@ protected void trySearchNewRecipeDistinct() { // Our caching implementation // This guarantees that if we get a recipe cache hit, our efficiency is no different from other machines - if (previousRecipe != null && previousRecipe.matches(false, importInventory.get(lastRecipeIndex), importFluids)) { + if (previousRecipe != null && previousRecipe.matches(false, importInventory.get(lastRecipeIndex), importFluids) && checkRecipe(previousRecipe)) { currentRecipe = previousRecipe; currentDistinctInputBus = importInventory.get(lastRecipeIndex); currentRecipe = findParallelRecipe( @@ -153,7 +154,7 @@ protected void trySearchNewRecipeDistinct() { importFluids, exportInventory, exportFluids, - maxVoltage, metaTileEntity.getParallelLimit()); + maxVoltage, getParallelLimit()); // If a valid recipe is found, immediately attempt to return it to prevent inventory scanning if (currentRecipe != null && setupAndConsumeRecipeInputs(currentRecipe, importInventory.get(lastRecipeIndex))) { @@ -179,7 +180,7 @@ protected void trySearchNewRecipeDistinct() { // Look for a new recipe after a cache miss currentRecipe = findRecipe(maxVoltage, bus, importFluids, MatchingMode.DEFAULT); // Cache the current recipe, if one is found - if (currentRecipe != null) { + if (currentRecipe != null && checkRecipe(currentRecipe)) { this.previousRecipe = currentRecipe; currentDistinctInputBus = bus; currentRecipe = findParallelRecipe( @@ -189,7 +190,7 @@ protected void trySearchNewRecipeDistinct() { importFluids, exportInventory, exportFluids, - maxVoltage, metaTileEntity.getParallelLimit()); + maxVoltage,getParallelLimit()); if (currentRecipe != null && setupAndConsumeRecipeInputs(currentRecipe, importInventory.get(i))) { lastRecipeIndex = i; @@ -202,7 +203,7 @@ protected void trySearchNewRecipeDistinct() { } } - //If no matching recipes are found, clear the notified inputs so we know when new items are given + //If no matching recipes are found, clear the notified inputs so that we know when new items are given metaTileEntity.getNotifiedItemInputList().clear(); } @@ -218,7 +219,7 @@ public void invalidateInputs() { } @Override - protected int[] calculateOverclock(int EUt, long voltage, int duration) { + protected int[] runOverclockingLogic(@Nonnull Recipe recipe, boolean negativeEU, int maxOverclocks) { // apply maintenance penalties MultiblockWithDisplayBase displayBase = this.metaTileEntity instanceof MultiblockWithDisplayBase ? (MultiblockWithDisplayBase) metaTileEntity : null; int numMaintenanceProblems = displayBase == null ? 0 : displayBase.getNumMaintenanceProblems(); @@ -228,27 +229,32 @@ protected int[] calculateOverclock(int EUt, long voltage, int duration) { IMaintenanceHatch hatch = displayBase.getAbilities(MultiblockAbility.MAINTENANCE_HATCH).get(0); double durationMultiplier = hatch.getDurationMultiplier(); if (durationMultiplier != 1.0) { - overclock = super.calculateOverclock(EUt, voltage, (int) Math.round(duration * durationMultiplier)); + overclock = standardOverclockingLogic(recipe.getEUt() * (negativeEU ? -1 : 1), getMaxVoltage(), (int) Math.round(recipe.getDuration() * durationMultiplier), getOverclockingDurationDivisor(), getOverclockingVoltageMultiplier(), maxOverclocks); } } - if (overclock == null) overclock = super.calculateOverclock(EUt, voltage, duration); + if (overclock == null) overclock = super.runOverclockingLogic(recipe, negativeEU, maxOverclocks); overclock[1] = (int) (overclock[1] * (1 + 0.1 * numMaintenanceProblems)); return overclock; } @Override - protected boolean setupAndConsumeRecipeInputs(Recipe recipe, IItemHandlerModifiable importInventory) { + protected boolean checkRecipe(Recipe recipe) { RecipeMapMultiblockController controller = (RecipeMapMultiblockController) metaTileEntity; - if (controller.checkRecipe(recipe, false) && - super.setupAndConsumeRecipeInputs(recipe, importInventory)) { + if (controller.checkRecipe(recipe, false)) { controller.checkRecipe(recipe, true); - return true; - } else return false; + return super.checkRecipe(recipe); + } + return false; } @Override protected void completeRecipe() { + super.completeRecipe(); + performMaintenanceMufflerOperations(); + } + + protected void performMaintenanceMufflerOperations() { if (metaTileEntity instanceof MultiblockWithDisplayBase) { MultiblockWithDisplayBase controller = (MultiblockWithDisplayBase) metaTileEntity; @@ -263,7 +269,6 @@ protected void completeRecipe() { if (controller.hasMaintenanceMechanics()) controller.calculateMaintenance(this.progressTime); } - super.completeRecipe(); } @Override diff --git a/src/main/java/gregtech/api/capability/impl/PrimitiveRecipeLogic.java b/src/main/java/gregtech/api/capability/impl/PrimitiveRecipeLogic.java index 9f5c2bf6804..1fb62b13e73 100644 --- a/src/main/java/gregtech/api/capability/impl/PrimitiveRecipeLogic.java +++ b/src/main/java/gregtech/api/capability/impl/PrimitiveRecipeLogic.java @@ -2,8 +2,11 @@ import gregtech.api.GTValues; import gregtech.api.metatileentity.multiblock.RecipeMapPrimitiveMultiblockController; +import gregtech.api.recipes.Recipe; import gregtech.api.recipes.RecipeMap; +import javax.annotation.Nonnull; + /** * Recipe Logic for a Multiblock that does not require power. */ @@ -39,13 +42,19 @@ protected long getMaxVoltage() { } @Override - protected int[] calculateOverclock(int EUt, long voltage, int duration) { - return new int[]{1, duration}; + protected int[] runOverclockingLogic(@Nonnull Recipe recipe, boolean negativeEU, int maxOverclocks) { + return standardOverclockingLogic(1, + getMaxVoltage(), + recipe.getDuration(), + getOverclockingDurationDivisor(), + getOverclockingVoltageMultiplier(), + maxOverclocks + ); } @Override - protected int getOverclockingTier(long voltage) { - return GTValues.LV; // just return something reasonable + public long getOverclockVoltage() { + return GTValues.V[GTValues.LV]; } /** diff --git a/src/main/java/gregtech/api/capability/impl/RecipeLogicSteam.java b/src/main/java/gregtech/api/capability/impl/RecipeLogicSteam.java index 36d9d02d784..4c97d54386d 100644 --- a/src/main/java/gregtech/api/capability/impl/RecipeLogicSteam.java +++ b/src/main/java/gregtech/api/capability/impl/RecipeLogicSteam.java @@ -21,7 +21,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldServer; import net.minecraftforge.fluids.IFluidTank; -import net.minecraftforge.items.IItemHandlerModifiable; + +import javax.annotation.Nonnull; public class RecipeLogicSteam extends AbstractRecipeLogic { @@ -156,8 +157,8 @@ public void update() { } @Override - protected boolean setupAndConsumeRecipeInputs(Recipe recipe, IItemHandlerModifiable importInventory) { - return !this.needsVenting && super.setupAndConsumeRecipeInputs(recipe, importInventory); + protected boolean checkRecipe(Recipe recipe) { + return super.checkRecipe(recipe) && !this.needsVenting; } @Override @@ -167,12 +168,14 @@ protected void completeRecipe() { } @Override - protected int[] calculateOverclock(int EUt, long voltage, int duration) { - // double duration for normal Steam machines, double EUt for HP Steam - return new int[]{ - isHighPressure ? EUt * 2 : EUt, - isHighPressure ? duration : duration * 2 - }; + protected int[] runOverclockingLogic(@Nonnull Recipe recipe, boolean negativeEU, int maxOverclocks) { + return standardOverclockingLogic((isHighPressure ? recipe.getEUt() * 2 : recipe.getEUt()) * (negativeEU ? -1 : 1), + getMaxVoltage(), + isHighPressure ? recipe.getDuration() * 2 : recipe.getDuration(), + getOverclockingDurationDivisor(), + getOverclockingVoltageMultiplier(), + maxOverclocks + ); } @Override diff --git a/src/main/java/gregtech/api/capability/impl/SteamMultiblockRecipeLogic.java b/src/main/java/gregtech/api/capability/impl/SteamMultiblockRecipeLogic.java index 06b535791d3..e26dd95d7d3 100644 --- a/src/main/java/gregtech/api/capability/impl/SteamMultiblockRecipeLogic.java +++ b/src/main/java/gregtech/api/capability/impl/SteamMultiblockRecipeLogic.java @@ -29,7 +29,7 @@ public SteamMultiblockRecipeLogic(RecipeMapSteamMultiblockController tileEntity, super(tileEntity, recipeMap); this.steamFluidTank = steamFluidTank; this.conversionRate = conversionRate; - allowOverclocking = false; + setAllowOverclocking(false); combineSteamTanks(); } diff --git a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java index 31143804343..dda1e9fcd9b 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java @@ -45,7 +45,10 @@ import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.common.util.Constants.NBT; -import net.minecraftforge.fluids.*; +import net.minecraftforge.fluids.FluidActionResult; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTank; +import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fml.relauncher.Side; @@ -1294,10 +1297,6 @@ public List getNotifiedFluidOutputList() { return notifiedFluidOutputList; } - public int getParallelLimit() { - return 1; - } - public boolean isFragile() { return isFragile; } diff --git a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java index ff3c8c192b1..03f76c7dc30 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java @@ -74,7 +74,7 @@ public SimpleMachineMetaTileEntity(ResourceLocation metaTileEntityId, RecipeMap< @Override public MetaTileEntity createMetaTileEntity(MetaTileEntityHolder holder) { - return new SimpleMachineMetaTileEntity(metaTileEntityId, workable.recipeMap, renderer, getTier(), hasFrontFacing, getTankScalingFunction()); + return new SimpleMachineMetaTileEntity(metaTileEntityId, workable.getRecipeMap(), renderer, getTier(), hasFrontFacing, getTankScalingFunction()); } @Override @@ -396,7 +396,7 @@ protected RecipeLogicEnergy createWorkable(RecipeMap recipeMap) { } protected ModularUI.Builder createGuiTemplate(EntityPlayer player) { - RecipeMap workableRecipeMap = workable.recipeMap; + RecipeMap workableRecipeMap = workable.getRecipeMap(); int yOffset = 0; if (workableRecipeMap.getMaxInputs() >= 6 || workableRecipeMap.getMaxFluidInputs() >= 6 || workableRecipeMap.getMaxOutputs() >= 6 || workableRecipeMap.getMaxFluidOutputs() >= 6) { yOffset = FONT_HEIGHT; diff --git a/src/main/java/gregtech/api/metatileentity/WorkableTieredMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/WorkableTieredMetaTileEntity.java index 7bb3e508a32..0ae860fec38 100644 --- a/src/main/java/gregtech/api/metatileentity/WorkableTieredMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/WorkableTieredMetaTileEntity.java @@ -76,19 +76,19 @@ public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, @Override protected IItemHandlerModifiable createImportItemHandler() { if (workable == null) return new ItemStackHandler(0); - return new NotifiableItemStackHandler(workable.recipeMap.getMaxInputs(), this, false); + return new NotifiableItemStackHandler(workable.getRecipeMap().getMaxInputs(), this, false); } @Override protected IItemHandlerModifiable createExportItemHandler() { if (workable == null) return new ItemStackHandler(0); - return new NotifiableItemStackHandler(workable.recipeMap.getMaxOutputs(), this, true); + return new NotifiableItemStackHandler(workable.getRecipeMap().getMaxOutputs(), this, true); } @Override protected FluidTankList createImportFluidHandler() { if (workable == null) return new FluidTankList(false); - FilteredFluidHandler[] fluidImports = new FilteredFluidHandler[workable.recipeMap.getMaxFluidInputs()]; + FilteredFluidHandler[] fluidImports = new FilteredFluidHandler[workable.getRecipeMap().getMaxFluidInputs()]; for (int i = 0; i < fluidImports.length; i++) { NotifiableFilteredFluidHandler filteredFluidHandler = new NotifiableFilteredFluidHandler(this.tankScalingFunction.apply(this.getTier()), this, false); filteredFluidHandler.setFillPredicate(this::canInputFluid); @@ -100,7 +100,7 @@ protected FluidTankList createImportFluidHandler() { @Override protected FluidTankList createExportFluidHandler() { if (workable == null) return new FluidTankList(false); - FluidTank[] fluidExports = new FluidTank[workable.recipeMap.getMaxFluidOutputs()]; + FluidTank[] fluidExports = new FluidTank[workable.getRecipeMap().getMaxFluidOutputs()]; for (int i = 0; i < fluidExports.length; i++) { fluidExports[i] = new NotifiableFluidTank(this.tankScalingFunction.apply(this.getTier()), this, true); } @@ -108,7 +108,7 @@ protected FluidTankList createExportFluidHandler() { } protected boolean canInputFluid(FluidStack inputFluid) { - RecipeMap recipeMap = workable.recipeMap; + RecipeMap recipeMap = workable.getRecipeMap(); if (recipeMap.canInputFluidForce(inputFluid.getFluid())) return true; //if recipe map forces input of given fluid, return true Set matchingRecipes = null; diff --git a/src/main/java/gregtech/api/metatileentity/multiblock/RecipeMapMultiblockController.java b/src/main/java/gregtech/api/metatileentity/multiblock/RecipeMapMultiblockController.java index 5b5edd17b13..e32f6cb32f0 100644 --- a/src/main/java/gregtech/api/metatileentity/multiblock/RecipeMapMultiblockController.java +++ b/src/main/java/gregtech/api/metatileentity/multiblock/RecipeMapMultiblockController.java @@ -190,8 +190,8 @@ protected void addDisplayText(List textList) { } else if (recipeMapWorkable.isActive()) { textList.add(new TextComponentTranslation("gregtech.multiblock.running")); int currentProgress = (int) (recipeMapWorkable.getProgressPercent() * 100); - if (this.getParallelLimit() != 1) { - textList.add(new TextComponentTranslation("gregtech.multiblock.parallel", this.getParallelLimit())); + if (this.recipeMapWorkable.getParallelLimit() != 1) { + textList.add(new TextComponentTranslation("gregtech.multiblock.parallel", this.recipeMapWorkable.getParallelLimit())); } textList.add(new TextComponentTranslation("gregtech.multiblock.progress", currentProgress)); } else { diff --git a/src/main/java/gregtech/api/metatileentity/multiblock/RecipeMapPrimitiveMultiblockController.java b/src/main/java/gregtech/api/metatileentity/multiblock/RecipeMapPrimitiveMultiblockController.java index f2c5c4c4040..ec06573cdc0 100644 --- a/src/main/java/gregtech/api/metatileentity/multiblock/RecipeMapPrimitiveMultiblockController.java +++ b/src/main/java/gregtech/api/metatileentity/multiblock/RecipeMapPrimitiveMultiblockController.java @@ -21,10 +21,10 @@ public RecipeMapPrimitiveMultiblockController(ResourceLocation metaTileEntityId, // just initialize inventories based on RecipeMap values by default protected void initializeAbilities() { - this.importItems = new NotifiableItemStackHandler(recipeMapWorkable.recipeMap.getMaxInputs(), this, false); - this.importFluids = new FluidTankList(true, makeFluidTanks(recipeMapWorkable.recipeMap.getMaxFluidInputs(), false)); - this.exportItems = new NotifiableItemStackHandler(recipeMapWorkable.recipeMap.getMaxOutputs(), this, true); - this.exportFluids = new FluidTankList(false, makeFluidTanks(recipeMapWorkable.recipeMap.getMaxFluidOutputs(), true)); + this.importItems = new NotifiableItemStackHandler(recipeMapWorkable.getRecipeMap().getMaxInputs(), this, false); + this.importFluids = new FluidTankList(true, makeFluidTanks(recipeMapWorkable.getRecipeMap().getMaxFluidInputs(), false)); + this.exportItems = new NotifiableItemStackHandler(recipeMapWorkable.getRecipeMap().getMaxOutputs(), this, true); + this.exportFluids = new FluidTankList(false, makeFluidTanks(recipeMapWorkable.getRecipeMap().getMaxFluidOutputs(), true)); this.itemInventory = new ItemHandlerProxy(this.importItems, this.exportItems); this.fluidInventory = new FluidHandlerProxy(this.importFluids, this.exportFluids); diff --git a/src/main/java/gregtech/api/metatileentity/multiblock/RecipeMapSteamMultiblockController.java b/src/main/java/gregtech/api/metatileentity/multiblock/RecipeMapSteamMultiblockController.java index be2d6ef2b91..eaa7a9ffb84 100644 --- a/src/main/java/gregtech/api/metatileentity/multiblock/RecipeMapSteamMultiblockController.java +++ b/src/main/java/gregtech/api/metatileentity/multiblock/RecipeMapSteamMultiblockController.java @@ -109,8 +109,8 @@ protected void addDisplayText(List textList) { } else if (recipeMapWorkable.isActive()) { textList.add(new TextComponentTranslation("gregtech.multiblock.running")); int currentProgress = (int) (recipeMapWorkable.getProgressPercent() * 100); - if (this.getParallelLimit() != 1) { - textList.add(new TextComponentTranslation("gregtech.multiblock.parallel", this.getParallelLimit())); + if (this.recipeMapWorkable.getParallelLimit() != 1) { + textList.add(new TextComponentTranslation("gregtech.multiblock.parallel", this.recipeMapWorkable.getParallelLimit())); } textList.add(new TextComponentTranslation("gregtech.multiblock.progress", currentProgress)); } else { diff --git a/src/main/java/gregtech/api/recipes/logic/IParallelableRecipeLogic.java b/src/main/java/gregtech/api/recipes/logic/IParallelableRecipeLogic.java index e7d2cc98bc4..338208d49df 100644 --- a/src/main/java/gregtech/api/recipes/logic/IParallelableRecipeLogic.java +++ b/src/main/java/gregtech/api/recipes/logic/IParallelableRecipeLogic.java @@ -8,6 +8,8 @@ import gregtech.api.recipes.RecipeMap; import net.minecraftforge.items.IItemHandlerModifiable; +import javax.annotation.Nonnull; + public interface IParallelableRecipeLogic { /** @@ -16,7 +18,7 @@ public interface IParallelableRecipeLogic { * * @param builder the recipe builder */ - default void applyParallelBonus(RecipeBuilder builder) { + default void applyParallelBonus(@Nonnull RecipeBuilder builder) { } /** @@ -66,9 +68,9 @@ default Recipe findParallelRecipe(AbstractRecipeLogic logic, Recipe currentRecip if (parallelLimit > 1) { RecipeBuilder parallelBuilder = null; if (logic.getParallelLogicType() == ParallelLogicType.MULTIPLY) { - parallelBuilder = findMultipliedParallelRecipe(logic.recipeMap, currentRecipe, inputs, fluidInputs, outputs, fluidOutputs, parallelLimit); + parallelBuilder = findMultipliedParallelRecipe(logic.getRecipeMap(), currentRecipe, inputs, fluidInputs, outputs, fluidOutputs, parallelLimit); } else if (logic.getParallelLogicType() == ParallelLogicType.APPEND_ITEMS) { - parallelBuilder = findAppendedParallelItemRecipe(logic.recipeMap, inputs, outputs, parallelLimit, maxVoltage); + parallelBuilder = findAppendedParallelItemRecipe(logic.getRecipeMap(), inputs, outputs, parallelLimit, maxVoltage); } // if the builder returned is null, no recipe was found. if (parallelBuilder == null) { diff --git a/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityGasCollector.java b/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityGasCollector.java index c591316833d..eb809a8a7e4 100644 --- a/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityGasCollector.java +++ b/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityGasCollector.java @@ -1,12 +1,10 @@ package gregtech.common.metatileentities.electric; import gregtech.api.capability.IEnergyContainer; -import gregtech.api.capability.IMultipleTankHandler; import gregtech.api.capability.impl.RecipeLogicEnergy; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.MetaTileEntityHolder; import gregtech.api.metatileentity.SimpleMachineMetaTileEntity; -import gregtech.api.recipes.MatchingMode; import gregtech.api.recipes.Recipe; import gregtech.api.recipes.RecipeMap; import gregtech.api.recipes.RecipeMaps; @@ -14,8 +12,8 @@ import gregtech.api.render.OrientedOverlayRenderer; import gregtech.api.render.Textures; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.items.IItemHandlerModifiable; +import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.List; import java.util.function.Function; @@ -41,7 +39,7 @@ protected RecipeLogicEnergy createWorkable(RecipeMap recipeMap) { return result; } - protected boolean checkRecipe(Recipe recipe) { + protected boolean checkRecipe(@Nonnull Recipe recipe) { List recipeDimensions = recipe.getProperty(GasCollectorDimensionProperty.getInstance(), new ArrayList<>()); for (Integer dimension : recipeDimensions) { if (dimension == this.getWorld().provider.getDimension()) { @@ -58,30 +56,8 @@ public GasCollectorRecipeLogic(MetaTileEntity metaTileEntity, RecipeMap recip } @Override - protected void trySearchNewRecipe() { - long maxVoltage = getMaxVoltage(); - Recipe currentRecipe = null; - IItemHandlerModifiable importInventory = getInputInventory(); - IMultipleTankHandler importFluids = getInputTank(); - - // see if the last recipe we used still works - if (this.previousRecipe != null && this.previousRecipe.matches(false, importInventory, importFluids)) - currentRecipe = this.previousRecipe; - // If there is no active recipe, then we need to find one. - else { - currentRecipe = findRecipe(maxVoltage, importInventory, importFluids, MatchingMode.IGNORE_FLUIDS); - } - // If a recipe was found, then inputs were valid. Cache found recipe. - if (currentRecipe != null) { - this.previousRecipe = currentRecipe; - } - this.invalidInputsForRecipes = (currentRecipe == null); - // proceed if we have a usable recipe. - if (currentRecipe != null && ((MetaTileEntityGasCollector) metaTileEntity).checkRecipe(currentRecipe) && setupAndConsumeRecipeInputs(currentRecipe, importInventory)) - setupRecipe(currentRecipe); - // Inputs have been inspected. - metaTileEntity.getNotifiedItemInputList().clear(); - metaTileEntity.getNotifiedFluidInputList().clear(); + protected boolean checkRecipe(Recipe recipe) { + return ((MetaTileEntityGasCollector) metaTileEntity).checkRecipe(recipe); } } } diff --git a/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityMacerator.java b/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityMacerator.java index b10b12e9c90..6c7634a4729 100644 --- a/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityMacerator.java +++ b/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityMacerator.java @@ -1,15 +1,12 @@ package gregtech.common.metatileentities.electric; import gregtech.api.GTValues; -import gregtech.api.capability.impl.RecipeLogicEnergy; +import gregtech.api.capability.impl.NotifiableItemStackHandler; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.MetaTileEntityHolder; import gregtech.api.metatileentity.SimpleMachineMetaTileEntity; -import gregtech.api.recipes.Recipe; import gregtech.api.recipes.RecipeMap; import gregtech.api.render.OrientedOverlayRenderer; -import gregtech.api.util.GTUtility; -import gregtech.api.capability.impl.NotifiableItemStackHandler; import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @@ -29,22 +26,6 @@ public MetaTileEntityMacerator(ResourceLocation metaTileEntityId, RecipeMap r initializeInventory(); } - @Override - protected RecipeLogicEnergy createWorkable(RecipeMap recipeMap) { - final RecipeLogicEnergy result = new RecipeLogicEnergy(this, recipeMap, () -> energyContainer) { - @Override - protected int getMachineTierForRecipe(Recipe recipe) { - int tier = GTUtility.getTierByVoltage(getMaxVoltage()); - if (tier > GTValues.MV) { - return tier - GTValues.MV; - } - return 0; - } - }; - result.enableOverclockVoltage(); - return result; - } - @Override protected IItemHandlerModifiable createExportItemHandler() { return new NotifiableItemStackHandler(outputAmount, this, true); @@ -52,7 +33,7 @@ protected IItemHandlerModifiable createExportItemHandler() { @Override public MetaTileEntity createMetaTileEntity(MetaTileEntityHolder holder) { - return new MetaTileEntityMacerator(metaTileEntityId, workable.recipeMap, outputAmount, renderer, getTier()); + return new MetaTileEntityMacerator(metaTileEntityId, workable.getRecipeMap(), outputAmount, renderer, getTier()); } @Override diff --git a/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntitySimpleOreWasher.java b/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntitySimpleOreWasher.java index 4e6140cb5ca..8219aeafdab 100644 --- a/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntitySimpleOreWasher.java +++ b/src/main/java/gregtech/common/metatileentities/electric/MetaTileEntitySimpleOreWasher.java @@ -23,6 +23,6 @@ protected IItemHandlerModifiable createExportItemHandler() { @Override public MetaTileEntity createMetaTileEntity(MetaTileEntityHolder holder) { - return new MetaTileEntitySimpleOreWasher(metaTileEntityId, workable.recipeMap, renderer, getTier()); + return new MetaTileEntitySimpleOreWasher(metaTileEntityId, workable.getRecipeMap(), renderer, getTier()); } } diff --git a/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityElectricBlastFurnace.java b/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityElectricBlastFurnace.java index c3317ab587a..602921e3147 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityElectricBlastFurnace.java +++ b/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityElectricBlastFurnace.java @@ -1,13 +1,11 @@ package gregtech.common.metatileentities.multi.electric; import gregtech.api.GTValues; -import gregtech.api.capability.IMaintenanceHatch; import gregtech.api.capability.impl.MultiblockRecipeLogic; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.MetaTileEntityHolder; import gregtech.api.metatileentity.multiblock.IMultiblockPart; import gregtech.api.metatileentity.multiblock.MultiblockAbility; -import gregtech.api.metatileentity.multiblock.MultiblockWithDisplayBase; import gregtech.api.metatileentity.multiblock.RecipeMapMultiblockController; import gregtech.api.multiblock.BlockPattern; import gregtech.api.multiblock.BlockWorldState; @@ -95,9 +93,8 @@ public void invalidateStructure() { } @Override - public boolean checkRecipe(Recipe recipe, boolean consumeIfSuccess) { - int recipeRequiredTemp = recipe.getProperty(BlastTemperatureProperty.getInstance(), 0); - return this.blastFurnaceTemperature >= recipeRequiredTemp; + public boolean checkRecipe(@Nonnull Recipe recipe, boolean consumeIfSuccess) { + return this.blastFurnaceTemperature >= recipe.getProperty(BlastTemperatureProperty.getInstance(), 0); } public static Predicate heatingCoilPredicate() { @@ -180,75 +177,31 @@ public ElectricBlastFurnaceWorkableHandler(RecipeMapMultiblockController tileEnt } @Override - protected void setupRecipe(Recipe recipe) { - int[] resultOverclock = calculateOverclock(recipe.getEUt(), this.getMaxVoltage(), recipe.getDuration(), + protected int[] runOverclockingLogic(@Nonnull Recipe recipe, boolean negativeEU, int maxOverclocks) { + return blastFurnaceOverclockingLogic(recipe.getEUt(), getMaxVoltage(), recipe.getDuration(), maxOverclocks, + ((MetaTileEntityElectricBlastFurnace) metaTileEntity).getBlastFurnaceTemperature(), recipe.getProperty(BlastTemperatureProperty.getInstance(), 0)); - - this.progressTime = 1; - setMaxProgress(resultOverclock[1]); - this.recipeEUt = resultOverclock[0]; - this.fluidOutputs = GTUtility.copyFluidList(recipe.getFluidOutputs()); - int tier = getMachineTierForRecipe(recipe); - this.itemOutputs = GTUtility.copyStackList(recipe.getResultItemOutputs(getOutputInventory().getSlots(), random, tier)); - if (this.wasActiveAndNeedsUpdate) { - this.wasActiveAndNeedsUpdate = false; - } else { - this.setActive(true); - } } - protected int[] calculateOverclock(int EUt, long voltage, int duration, int recipeRequiredTemp) { - if (!allowOverclocking) { - return new int[]{EUt, duration}; - } - boolean negativeEU = EUt < 0; - - int blastFurnaceTemperature = ((MetaTileEntityElectricBlastFurnace) this.metaTileEntity).getBlastFurnaceTemperature(); - int amountEUDiscount = Math.max(0, (blastFurnaceTemperature - recipeRequiredTemp) / 900); + @Nonnull + public static int[] blastFurnaceOverclockingLogic(int recipeEUt, long maximumVoltage, int recipeDuration, int maxOverclocks, int currentTemp, int recipeRequiredTemp) { + int amountEUDiscount = Math.max(0, (currentTemp - recipeRequiredTemp) / 900); int amountPerfectOC = amountEUDiscount / 2; - //apply a multiplicative 95% energy multiplier for every 900k over recipe temperature - EUt *= Math.min(1, Math.pow(0.95, amountEUDiscount)); - - // Apply Configurable Maintenance effects - double resultDuration = duration; - MultiblockWithDisplayBase displayBase = (MultiblockWithDisplayBase) metaTileEntity; - int numMaintenanceProblems = ((MultiblockWithDisplayBase) metaTileEntity).getNumMaintenanceProblems(); - if (((MetaTileEntityElectricBlastFurnace) metaTileEntity).hasMaintenanceMechanics()) { - IMaintenanceHatch hatch = displayBase.getAbilities(MultiblockAbility.MAINTENANCE_HATCH).get(0); - if (hatch.getDurationMultiplier() != 1.0) { - resultDuration *= hatch.getDurationMultiplier(); - } - } - - int tier = getOverclockingTier(voltage); - if (GTValues.V[tier] <= EUt || tier == 0) - return new int[]{EUt, duration}; - if (negativeEU) - EUt = -EUt; - - int resultEUt = EUt; + // apply a multiplicative 95% energy multiplier for every 900k over recipe temperature + recipeEUt *= Math.min(1, Math.pow(0.95, amountEUDiscount)); - //do not overclock further if duration is already too small - //perfect overclock for every 1800k over recipe temperature - while (resultDuration >= 3 && resultEUt <= GTValues.V[tier - 1] && amountPerfectOC > 0) { - resultEUt *= 4; - resultDuration /= 4; - amountPerfectOC--; - } + // perfect overclock for every 1800k over recipe temperature + if (amountPerfectOC > 0) { + // use the normal overclock logic to do perfect OCs up to as many times as calculated + int[] overclock = standardOverclockingLogic(recipeEUt, maximumVoltage, recipeDuration, PERFECT_OVERCLOCK_DURATION_DIVISOR, STANDARD_OVERCLOCK_VOLTAGE_MULTIPLIER, amountPerfectOC); - //do not overclock further if duration is already too small - //regular overclocking - while (resultDuration >= 3 && resultEUt <= GTValues.V[tier - 1]) { - resultEUt *= 4; - resultDuration /= ConfigHolder.U.overclockDivisor; + // overclock normally as much as possible after perfects are exhausted + return standardOverclockingLogic(overclock[0], maximumVoltage, overclock[1], STANDARD_OVERCLOCK_DURATION_DIVISOR, STANDARD_OVERCLOCK_VOLTAGE_MULTIPLIER, maxOverclocks); } - // apply maintenance slowdown - resultDuration = (int) (resultDuration * (1 + 0.1 * numMaintenanceProblems)); - - return new int[]{negativeEU ? -resultEUt : resultEUt, (int) Math.ceil(resultDuration)}; - + // no perfects are performed, do normal overclocking + return standardOverclockingLogic(recipeEUt, maximumVoltage, recipeDuration, STANDARD_OVERCLOCK_DURATION_DIVISOR, STANDARD_OVERCLOCK_VOLTAGE_MULTIPLIER, maxOverclocks); } } } diff --git a/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityFusionReactor.java b/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityFusionReactor.java index 1274f785f38..47e90719fac 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityFusionReactor.java +++ b/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityFusionReactor.java @@ -2,7 +2,6 @@ import gregtech.api.GTValues; import gregtech.api.capability.IEnergyContainer; -import gregtech.api.capability.IMultipleTankHandler; import gregtech.api.capability.impl.*; import gregtech.api.metatileentity.IFastRenderMetaTileEntity; import gregtech.api.metatileentity.MetaTileEntity; @@ -13,7 +12,6 @@ import gregtech.api.multiblock.BlockPattern; import gregtech.api.multiblock.FactoryBlockPattern; import gregtech.api.multiblock.PatternMatchContext; -import gregtech.api.recipes.MatchingMode; import gregtech.api.recipes.Recipe; import gregtech.api.recipes.RecipeMaps; import gregtech.api.recipes.recipeproperties.FusionEUToStartProperty; @@ -48,7 +46,6 @@ import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import net.minecraftforge.items.IItemHandlerModifiable; import org.lwjgl.opengl.GL11; import javax.annotation.Nonnull; @@ -212,7 +209,7 @@ private class FusionRecipeLogic extends MultiblockRecipeLogic { public FusionRecipeLogic(MetaTileEntityFusionReactor tileEntity) { super(tileEntity); - this.allowOverclocking = false; + this.setAllowOverclocking(false); } @Override @@ -224,22 +221,23 @@ public void updateWorkable() { } @Override - protected Recipe findRecipe(long maxVoltage, IItemHandlerModifiable inputs, IMultipleTankHandler fluidInputs, MatchingMode mode) { - Recipe recipe = super.findRecipe(maxVoltage, inputs, fluidInputs, mode); - return (recipe != null && recipe.getProperty(FusionEUToStartProperty.getInstance(), 0L) - <= energyContainer.getEnergyCapacity()) ? recipe : null; - } + protected boolean checkRecipe(Recipe recipe) { + // if the reactor is not able to hold enough energy for it, do not run the recipe + if (recipe.getProperty(FusionEUToStartProperty.getInstance(), 0L) > energyContainer.getEnergyCapacity()) + return false; - @Override - protected boolean setupAndConsumeRecipeInputs(Recipe recipe, IItemHandlerModifiable importInventory) { long heatDiff = recipe.getProperty(FusionEUToStartProperty.getInstance(), 0L) - heat; - if (heatDiff <= 0) { - return super.setupAndConsumeRecipeInputs(recipe, importInventory); - } - if (energyContainer.getEnergyStored() < heatDiff || !super.setupAndConsumeRecipeInputs(recipe, importInventory)) { + // if the stored heat is >= required energy, recipe is okay to run + if (heatDiff <= 0) + return true; + + // if the remaining energy needed is more than stored, do not run + if (energyContainer.getEnergyStored() < heatDiff) return false; - } + + // remove the energy needed energyContainer.removeEnergy(heatDiff); + // increase the stored heat heat += heatDiff; return true; } diff --git a/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityMultiSmelter.java b/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityMultiSmelter.java index 33773cbf875..6bdeca47201 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityMultiSmelter.java +++ b/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityMultiSmelter.java @@ -1,6 +1,5 @@ package gregtech.common.metatileentities.multi.electric; -import gregtech.api.capability.IMultipleTankHandler; import gregtech.api.capability.impl.MultiblockRecipeLogic; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.MetaTileEntityHolder; @@ -11,7 +10,8 @@ import gregtech.api.multiblock.BlockPattern; import gregtech.api.multiblock.FactoryBlockPattern; import gregtech.api.multiblock.PatternMatchContext; -import gregtech.api.recipes.*; +import gregtech.api.recipes.RecipeBuilder; +import gregtech.api.recipes.RecipeMaps; import gregtech.api.render.ICubeRenderer; import gregtech.api.render.OrientedOverlayRenderer; import gregtech.api.render.Textures; @@ -23,10 +23,9 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentTranslation; -import net.minecraftforge.items.IItemHandlerModifiable; import javax.annotation.Nonnull; -import java.util.*; +import java.util.List; public class MetaTileEntityMultiSmelter extends RecipeMapMultiblockController { @@ -80,11 +79,6 @@ public void invalidateStructure() { this.heatingCoilDiscount = 0; } - @Override - public int getParallelLimit() { - return heatingCoilLevel * 32; - } - @Override protected BlockPattern createStructurePattern() { return FactoryBlockPattern.start() @@ -133,10 +127,14 @@ public ParallelLogicType getParallelLogicType() { } @Override - public void applyParallelBonus(RecipeBuilder builder) { - int parallelLimit = 32 * heatingCoilLevel; + public void applyParallelBonus(@Nonnull RecipeBuilder builder) { builder.EUt(Math.max(1, 16 / heatingCoilDiscount)) - .duration((int) Math.max(1.0, 256 * builder.getParallel() / (parallelLimit * 1.0))); + .duration((int) Math.max(1.0, 256 * builder.getParallel() / (getParallelLimit() * 1.0))); + } + + @Override + public int getParallelLimit() { + return 32 * heatingCoilLevel; } } } diff --git a/src/main/java/gregtech/common/metatileentities/multi/steam/MetaTileEntitySteamGrinder.java b/src/main/java/gregtech/common/metatileentities/multi/steam/MetaTileEntitySteamGrinder.java index 1080658470d..2cfdd39f5b1 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/steam/MetaTileEntitySteamGrinder.java +++ b/src/main/java/gregtech/common/metatileentities/multi/steam/MetaTileEntitySteamGrinder.java @@ -1,11 +1,11 @@ package gregtech.common.metatileentities.multi.steam; -import gregtech.api.metatileentity.multiblock.RecipeMapSteamMultiblockController; import gregtech.api.capability.impl.SteamMultiWorkable; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.MetaTileEntityHolder; import gregtech.api.metatileentity.multiblock.IMultiblockPart; import gregtech.api.metatileentity.multiblock.MultiblockAbility; +import gregtech.api.metatileentity.multiblock.RecipeMapSteamMultiblockController; import gregtech.api.multiblock.BlockPattern; import gregtech.api.multiblock.FactoryBlockPattern; import gregtech.api.recipes.RecipeMaps; @@ -32,6 +32,7 @@ public class MetaTileEntitySteamGrinder extends RecipeMapSteamMultiblockControll public MetaTileEntitySteamGrinder(ResourceLocation metaTileEntityId) { super(metaTileEntityId, RecipeMaps.MACERATOR_RECIPES, CONVERSION_RATE); this.recipeMapWorkable = new SteamMultiWorkable(this, CONVERSION_RATE); + this.recipeMapWorkable.setParallelLimit(8); } @Override @@ -62,11 +63,6 @@ public ICubeRenderer getBaseTexture(IMultiblockPart sourcePart) { return ConfigHolder.U.steelSteamMultiblocks ? SOLID_STEEL_CASING : BRONZE_PLATED_BRICKS; } - @Override - public int getParallelLimit() { - return 8; - } - @Nonnull @Override protected OrientedOverlayRenderer getFrontOverlay() { diff --git a/src/main/java/gregtech/common/metatileentities/multi/steam/MetaTileEntitySteamOven.java b/src/main/java/gregtech/common/metatileentities/multi/steam/MetaTileEntitySteamOven.java index 123bdf4670d..843309fa3a9 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/steam/MetaTileEntitySteamOven.java +++ b/src/main/java/gregtech/common/metatileentities/multi/steam/MetaTileEntitySteamOven.java @@ -1,19 +1,18 @@ package gregtech.common.metatileentities.multi.steam; -import gregtech.api.metatileentity.multiblock.RecipeMapSteamMultiblockController; import gregtech.api.capability.impl.SteamMultiWorkable; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.MetaTileEntityHolder; import gregtech.api.metatileentity.multiblock.IMultiblockPart; import gregtech.api.metatileentity.multiblock.MultiblockAbility; +import gregtech.api.metatileentity.multiblock.RecipeMapSteamMultiblockController; import gregtech.api.multiblock.BlockPattern; import gregtech.api.multiblock.FactoryBlockPattern; import gregtech.api.recipes.RecipeMaps; import gregtech.api.render.ICubeRenderer; import gregtech.api.render.OrientedOverlayRenderer; import gregtech.api.render.Textures; -import gregtech.api.util.GTUtility; import gregtech.common.ConfigHolder; import gregtech.common.blocks.BlockFireboxCasing; import gregtech.common.blocks.BlockMetalCasing; @@ -34,6 +33,7 @@ public class MetaTileEntitySteamOven extends RecipeMapSteamMultiblockController public MetaTileEntitySteamOven(ResourceLocation metaTileEntityId) { super(metaTileEntityId, RecipeMaps.FURNACE_RECIPES, CONVERSION_RATE); this.recipeMapWorkable = new SteamMultiWorkable(this, CONVERSION_RATE); + this.recipeMapWorkable.setParallelLimit(8); } @Override @@ -170,11 +170,6 @@ public void receiveCustomData(int dataId, PacketBuffer buf) { } } - @Override - public int getParallelLimit() { - return 8; - } - @Nonnull @Override protected OrientedOverlayRenderer getFrontOverlay() { diff --git a/src/main/java/gregtech/common/metatileentities/steam/SteamAlloySmelter.java b/src/main/java/gregtech/common/metatileentities/steam/SteamAlloySmelter.java index b179971bb95..2491e1c7d21 100644 --- a/src/main/java/gregtech/common/metatileentities/steam/SteamAlloySmelter.java +++ b/src/main/java/gregtech/common/metatileentities/steam/SteamAlloySmelter.java @@ -3,7 +3,6 @@ import gregtech.api.capability.impl.NotifiableItemStackHandler; import gregtech.api.gui.ModularUI; import gregtech.api.gui.resources.TextureArea; -import gregtech.api.gui.widgets.ProgressWidget; import gregtech.api.gui.widgets.ProgressWidget.MoveType; import gregtech.api.gui.widgets.RecipeProgressWidget; import gregtech.api.gui.widgets.SlotWidget; @@ -50,7 +49,7 @@ public ModularUI createUI(EntityPlayer player) { .setBackgroundTexture(BRONZE_SLOT_BACKGROUND_TEXTURE, slotBackground)) .widget(new SlotWidget(this.importItems, 1, 35, 25) .setBackgroundTexture(BRONZE_SLOT_BACKGROUND_TEXTURE, slotBackground)) - .widget(new RecipeProgressWidget(workableHandler::getProgressPercent, 79, 26, 20, 16, workableHandler.recipeMap) + .widget(new RecipeProgressWidget(workableHandler::getProgressPercent, 79, 26, 20, 16, workableHandler.getRecipeMap()) .setProgressBar(getFullGuiTexture("progress_bar_%s_furnace"), getFullGuiTexture("progress_bar_%s_furnace_filled"), MoveType.HORIZONTAL)) diff --git a/src/main/java/gregtech/common/metatileentities/steam/SteamCompressor.java b/src/main/java/gregtech/common/metatileentities/steam/SteamCompressor.java index 99547e717d0..ad40a000645 100644 --- a/src/main/java/gregtech/common/metatileentities/steam/SteamCompressor.java +++ b/src/main/java/gregtech/common/metatileentities/steam/SteamCompressor.java @@ -2,7 +2,6 @@ import gregtech.api.capability.impl.NotifiableItemStackHandler; import gregtech.api.gui.ModularUI; -import gregtech.api.gui.widgets.ProgressWidget; import gregtech.api.gui.widgets.ProgressWidget.MoveType; import gregtech.api.gui.widgets.RecipeProgressWidget; import gregtech.api.gui.widgets.SlotWidget; @@ -41,7 +40,7 @@ public ModularUI createUI(EntityPlayer player) { return createUITemplate(player) .widget(new SlotWidget(this.importItems, 0, 53, 25) .setBackgroundTexture(BRONZE_SLOT_BACKGROUND_TEXTURE, getFullGuiTexture("slot_%s_compressor_background"))) - .widget(new RecipeProgressWidget(workableHandler::getProgressPercent, 78, 25, 20, 18, workableHandler.recipeMap) + .widget(new RecipeProgressWidget(workableHandler::getProgressPercent, 78, 25, 20, 18, workableHandler.getRecipeMap()) .setProgressBar(getFullGuiTexture("progress_bar_%s_compressor"), getFullGuiTexture("progress_bar_%s_compressor_filled"), MoveType.HORIZONTAL)) diff --git a/src/main/java/gregtech/common/metatileentities/steam/SteamExtractor.java b/src/main/java/gregtech/common/metatileentities/steam/SteamExtractor.java index 9aa35c2f3e0..de25a563f64 100644 --- a/src/main/java/gregtech/common/metatileentities/steam/SteamExtractor.java +++ b/src/main/java/gregtech/common/metatileentities/steam/SteamExtractor.java @@ -40,7 +40,7 @@ public ModularUI createUI(EntityPlayer player) { return createUITemplate(player) .widget(new SlotWidget(this.importItems, 0, 53, 25) .setBackgroundTexture(BRONZE_SLOT_BACKGROUND_TEXTURE, getFullGuiTexture("slot_%s_extractor_background"))) - .widget(new RecipeProgressWidget(workableHandler::getProgressPercent, 79, 25, 20, 18, workableHandler.recipeMap) + .widget(new RecipeProgressWidget(workableHandler::getProgressPercent, 79, 25, 20, 18, workableHandler.getRecipeMap()) .setProgressBar(getFullGuiTexture("progress_bar_%s_extractor"), getFullGuiTexture("progress_bar_%s_extractor_filled"), ProgressWidget.MoveType.HORIZONTAL)) diff --git a/src/main/java/gregtech/common/metatileentities/steam/SteamFurnace.java b/src/main/java/gregtech/common/metatileentities/steam/SteamFurnace.java index ed5fbe91918..8c8ad2b5a90 100644 --- a/src/main/java/gregtech/common/metatileentities/steam/SteamFurnace.java +++ b/src/main/java/gregtech/common/metatileentities/steam/SteamFurnace.java @@ -2,7 +2,6 @@ import gregtech.api.capability.impl.NotifiableItemStackHandler; import gregtech.api.gui.ModularUI; -import gregtech.api.gui.widgets.ProgressWidget; import gregtech.api.gui.widgets.ProgressWidget.MoveType; import gregtech.api.gui.widgets.RecipeProgressWidget; import gregtech.api.gui.widgets.SlotWidget; @@ -46,7 +45,7 @@ public ModularUI createUI(EntityPlayer player) { return createUITemplate(player) .widget(new SlotWidget(this.importItems, 0, 53, 25) .setBackgroundTexture(BRONZE_SLOT_BACKGROUND_TEXTURE, getFullGuiTexture("slot_%s_furnace_background"))) - .widget(new RecipeProgressWidget(workableHandler::getProgressPercent, 79, 26, 20, 16, workableHandler.recipeMap) + .widget(new RecipeProgressWidget(workableHandler::getProgressPercent, 79, 26, 20, 16, workableHandler.getRecipeMap()) .setProgressBar(getFullGuiTexture("progress_bar_%s_furnace"), getFullGuiTexture("progress_bar_%s_furnace_filled"), MoveType.HORIZONTAL)) diff --git a/src/main/java/gregtech/common/metatileentities/steam/SteamHammer.java b/src/main/java/gregtech/common/metatileentities/steam/SteamHammer.java index 0ba13e8f0b9..f17e38e5552 100644 --- a/src/main/java/gregtech/common/metatileentities/steam/SteamHammer.java +++ b/src/main/java/gregtech/common/metatileentities/steam/SteamHammer.java @@ -41,7 +41,7 @@ public ModularUI createUI(EntityPlayer player) { return createUITemplate(player) .widget(new SlotWidget(this.importItems, 0, 53, 25) .setBackgroundTexture(BRONZE_SLOT_BACKGROUND_TEXTURE, getFullGuiTexture("slot_%s_hammer_background"))) - .widget(new RecipeProgressWidget(workableHandler::getProgressPercent, 79, 25, 20, 18, workableHandler.recipeMap) + .widget(new RecipeProgressWidget(workableHandler::getProgressPercent, 79, 25, 20, 18, workableHandler.getRecipeMap()) .setProgressBar(getFullGuiTexture("progress_bar_%s_hammer"), getFullGuiTexture("progress_bar_%s_hammer_filled"), ProgressWidget.MoveType.VERTICAL)) diff --git a/src/main/java/gregtech/common/metatileentities/steam/SteamMacerator.java b/src/main/java/gregtech/common/metatileentities/steam/SteamMacerator.java index e4a20ce6633..84acd5e107b 100644 --- a/src/main/java/gregtech/common/metatileentities/steam/SteamMacerator.java +++ b/src/main/java/gregtech/common/metatileentities/steam/SteamMacerator.java @@ -1,7 +1,6 @@ package gregtech.common.metatileentities.steam; import gregtech.api.capability.impl.NotifiableItemStackHandler; -import gregtech.api.capability.impl.RecipeLogicSteam; import gregtech.api.gui.ModularUI; import gregtech.api.gui.widgets.ProgressWidget; import gregtech.api.gui.widgets.RecipeProgressWidget; @@ -19,8 +18,6 @@ public class SteamMacerator extends SteamMetaTileEntity { public SteamMacerator(ResourceLocation metaTileEntityId, boolean isHighPressure) { super(metaTileEntityId, RecipeMaps.MACERATOR_RECIPES, Textures.MACERATOR_OVERLAY, isHighPressure); - this.workableHandler = new RecipeLogicSteam(this, - workableHandler.recipeMap, isHighPressure, steamFluidTank, 1.0); } @Override @@ -43,7 +40,7 @@ public ModularUI createUI(EntityPlayer player) { return createUITemplate(player) .widget(new SlotWidget(this.importItems, 0, 53, 25) .setBackgroundTexture(BRONZE_SLOT_BACKGROUND_TEXTURE, getFullGuiTexture("slot_%s_macerator_background"))) - .widget(new RecipeProgressWidget(workableHandler::getProgressPercent, 79, 26, 21, 18, workableHandler.recipeMap) + .widget(new RecipeProgressWidget(workableHandler::getProgressPercent, 79, 26, 21, 18, workableHandler.getRecipeMap()) .setProgressBar(getFullGuiTexture("progress_bar_%s_macerator"), getFullGuiTexture("progress_bar_%s_macerator_filled"), ProgressWidget.MoveType.HORIZONTAL)) diff --git a/src/main/java/gregtech/common/metatileentities/steam/SteamRockBreaker.java b/src/main/java/gregtech/common/metatileentities/steam/SteamRockBreaker.java index 54958230056..84f196a9d3f 100644 --- a/src/main/java/gregtech/common/metatileentities/steam/SteamRockBreaker.java +++ b/src/main/java/gregtech/common/metatileentities/steam/SteamRockBreaker.java @@ -25,7 +25,7 @@ public class SteamRockBreaker extends SteamMetaTileEntity { public SteamRockBreaker(ResourceLocation metaTileEntityId, boolean isHighPressure) { super(metaTileEntityId, RecipeMaps.ROCK_BREAKER_RECIPES, Textures.ROCK_BREAKER_OVERLAY, isHighPressure); this.workableHandler = new SteamRockBreakerRecipeLogic(this, - workableHandler.recipeMap, isHighPressure, steamFluidTank, 1.0); + workableHandler.getRecipeMap(), isHighPressure, steamFluidTank, 1.0); } @Override @@ -60,7 +60,7 @@ public ModularUI createUI(EntityPlayer player) { return createUITemplate(player) .widget(new SlotWidget(this.importItems, 0, 53, 34) .setBackgroundTexture(BRONZE_SLOT_BACKGROUND_TEXTURE, getFullGuiTexture("overlay_%s_dust"))) - .widget(new RecipeProgressWidget(workableHandler::getProgressPercent, 79, 35, 21, 18, workableHandler.recipeMap) + .widget(new RecipeProgressWidget(workableHandler::getProgressPercent, 79, 35, 21, 18, workableHandler.getRecipeMap()) .setProgressBar(getFullGuiTexture("progress_bar_%s_macerator"), getFullGuiTexture("progress_bar_%s_macerator_filled"), ProgressWidget.MoveType.HORIZONTAL)) diff --git a/src/main/java/gregtech/integration/jei/GTJeiPlugin.java b/src/main/java/gregtech/integration/jei/GTJeiPlugin.java index 31e65010359..add32c52f32 100755 --- a/src/main/java/gregtech/integration/jei/GTJeiPlugin.java +++ b/src/main/java/gregtech/integration/jei/GTJeiPlugin.java @@ -130,7 +130,7 @@ public void register(IModRegistry registry) { if (metaTileEntity instanceof SteamMetaTileEntity) { deferredCatalysts.add((SteamMetaTileEntity) metaTileEntity); } else { - RecipeMap recipeMap = ((AbstractRecipeLogic) workableCapability).recipeMap; + RecipeMap recipeMap = ((AbstractRecipeLogic) workableCapability).getRecipeMap(); registry.addRecipeCatalyst(metaTileEntity.getStackForm(), GTValues.MODID + ":" + recipeMap.unlocalizedName); if (recipeMap instanceof RecipeMapFurnace) { registry.addRecipeCatalyst(metaTileEntity.getStackForm(), VanillaRecipeCategoryUid.SMELTING); @@ -144,7 +144,7 @@ public void register(IModRegistry registry) { } for (SteamMetaTileEntity steamMetaTileEntity : deferredCatalysts) { IControllable workableCapability = steamMetaTileEntity.getCapability(GregtechTileCapabilities.CAPABILITY_CONTROLLABLE, null); - RecipeMap recipeMap = ((AbstractRecipeLogic) workableCapability).recipeMap; + RecipeMap recipeMap = ((AbstractRecipeLogic) workableCapability).getRecipeMap(); registry.addRecipeCatalyst(steamMetaTileEntity.getStackForm(), GTValues.MODID + ":" + recipeMap.unlocalizedName); if (recipeMap instanceof RecipeMapFurnace) { registry.addRecipeCatalyst(steamMetaTileEntity.getStackForm(), VanillaRecipeCategoryUid.SMELTING); diff --git a/src/test/java/gregtech/api/recipes/logic/IParallelableRecipeLogicTest.java b/src/test/java/gregtech/api/recipes/logic/IParallelableRecipeLogicTest.java index 973ea18012b..09a990ec368 100644 --- a/src/test/java/gregtech/api/recipes/logic/IParallelableRecipeLogicTest.java +++ b/src/test/java/gregtech/api/recipes/logic/IParallelableRecipeLogicTest.java @@ -30,6 +30,8 @@ import org.junit.Test; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import static org.junit.Assert.*; @@ -87,13 +89,21 @@ public boolean checkRecipe(Recipe recipe, boolean consumeIfSuccess) { public boolean hasMaintenanceMechanics() { return false; } - - @Override - public int getParallelLimit() { - return 4; - } }); + try { + Field field = MetaTileEntityElectricBlastFurnace.class.getSuperclass().getDeclaredField("recipeMapWorkable"); + field.setAccessible(true); + + Object recipeMapWorkableField = field.get(mbt); + Method setParallelLimitMethod = recipeMapWorkableField.getClass().getSuperclass().getSuperclass().getDeclaredMethod("setParallelLimit", int.class); + setParallelLimitMethod.setAccessible(true); + + setParallelLimitMethod.invoke(recipeMapWorkableField, 4); + } catch (NoSuchFieldException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { + e.printStackTrace(); + } + //isValid() check in the dirtying logic requires both a metatileentity and a holder try { Field field = MetaTileEntity.class.getDeclaredField("holder");