aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java12
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_IntegratedOreFactory.java158
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java102
3 files changed, 176 insertions, 96 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java
index 01638c4427..0c91951e28 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java
@@ -3,11 +3,10 @@ package gregtech.common.tileentities.machines.multi;
import net.minecraft.item.ItemStack;
import gregtech.api.enums.HeatingCoilLevel;
-import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_ExtendedPowerMultiBlockBase;
public abstract class GT_MetaTileEntity_AbstractMultiFurnace<T extends GT_MetaTileEntity_AbstractMultiFurnace<T>>
- extends GT_MetaTileEntity_EnhancedMultiBlockBase<T> {
+ extends GT_MetaTileEntity_ExtendedPowerMultiBlockBase<T> {
private HeatingCoilLevel mCoilLevel;
@@ -24,13 +23,6 @@ public abstract class GT_MetaTileEntity_AbstractMultiFurnace<T extends GT_MetaTi
return true;
}
- protected boolean addBottomHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
- return addMaintenanceToMachineList(aTileEntity, aBaseCasingIndex)
- || addInputToMachineList(aTileEntity, aBaseCasingIndex)
- || addOutputToMachineList(aTileEntity, aBaseCasingIndex)
- || addEnergyInputToMachineList(aTileEntity, aBaseCasingIndex);
- }
-
@Override
public int getMaxEfficiency(ItemStack aStack) {
return 10000;
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_IntegratedOreFactory.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_IntegratedOreFactory.java
index 27998e97e1..48ab5a10f5 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_IntegratedOreFactory.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_IntegratedOreFactory.java
@@ -13,6 +13,7 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PROCESSING_AR
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PROCESSING_ARRAY_ACTIVE;
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PROCESSING_ARRAY_ACTIVE_GLOW;
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PROCESSING_ARRAY_GLOW;
+import static gregtech.api.enums.TickTime.SECOND;
import static gregtech.api.util.GT_StructureUtility.buildHatchAdder;
import static gregtech.api.util.GT_StructureUtility.ofFrame;
@@ -51,10 +52,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.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_Muffler;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_ExtendedPowerMultiBlockBase;
import gregtech.api.multitileentity.multiblock.casing.Glasses;
import gregtech.api.recipe.RecipeMaps;
import gregtech.api.recipe.check.CheckRecipeResult;
@@ -62,17 +60,20 @@ import gregtech.api.recipe.check.CheckRecipeResultRegistry;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
+import gregtech.api.util.GT_OverclockCalculator;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
-public class GT_MetaTileEntity_IntegratedOreFactory extends
- GT_MetaTileEntity_EnhancedMultiBlockBase<GT_MetaTileEntity_IntegratedOreFactory> implements ISurvivalConstructable {
+public class GT_MetaTileEntity_IntegratedOreFactory
+ extends GT_MetaTileEntity_ExtendedPowerMultiBlockBase<GT_MetaTileEntity_IntegratedOreFactory>
+ implements ISurvivalConstructable {
private static final int CASING_INDEX1 = 183;
private static final int CASING_INDEX2 = 49;
private static final int MAX_PARA = 1024;
+ private static final long RECIPE_EUT = 30;
private static final String STRUCTURE_PIECE_MAIN = "main";
private static final IStructureDefinition<GT_MetaTileEntity_IntegratedOreFactory> STRUCTURE_DEFINITION = StructureDefinition
.<GT_MetaTileEntity_IntegratedOreFactory>builder()
@@ -179,21 +180,6 @@ public class GT_MetaTileEntity_IntegratedOreFactory extends
super(aName);
}
- public boolean addFluidInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
- if (aTileEntity == null) return false;
- IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
- if (aMetaTileEntity == null) return false;
- if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) {
- ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
- ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = getRecipeMap();
- return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity);
- } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) {
- ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
- return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity);
- }
- return false;
- }
-
@Override
public IStructureDefinition<GT_MetaTileEntity_IntegratedOreFactory> getStructureDefinition() {
return STRUCTURE_DEFINITION;
@@ -253,11 +239,11 @@ public class GT_MetaTileEntity_IntegratedOreFactory extends
private static int getTime(int mode) {
return switch (mode) {
- case 0 -> 30 * 20;
- case 1 -> 15 * 20;
- case 2 -> 10 * 20;
- case 3 -> 20 * 20;
- case 4 -> 17 * 20;
+ case 0 -> 30 * SECOND;
+ case 1 -> 15 * SECOND;
+ case 2 -> 10 * SECOND;
+ case 3 -> 20 * SECOND;
+ case 4 -> 17 * SECOND;
default ->
// go to hell
1000000000;
@@ -272,13 +258,39 @@ public class GT_MetaTileEntity_IntegratedOreFactory extends
isInit = true;
}
- int tCharged = MAX_PARA;
List<ItemStack> tInput = getStoredInputs();
List<FluidStack> tInputFluid = getStoredFluids();
+ long availableEUt = getMaxInputVoltage();
+ if (availableEUt < RECIPE_EUT) {
+ return CheckRecipeResultRegistry.insufficientPower(RECIPE_EUT);
+ }
+ if (tInput.isEmpty() || tInputFluid.isEmpty()) {
+ return CheckRecipeResultRegistry.NO_RECIPE;
+ }
+
+ int maxParallel = MAX_PARA;
+ int originalMaxParallel = maxParallel;
+
+ GT_OverclockCalculator calculator = new GT_OverclockCalculator().setEUt(availableEUt)
+ .setRecipeEUt(RECIPE_EUT)
+ .setDuration(getTime(sMode));
+
+ double tickTimeAfterOC = calculator.setParallel(originalMaxParallel)
+ .calculateDurationUnderOneTick();
+
+ if (tickTimeAfterOC < 1) {
+ maxParallel = GT_Utility.safeInt((long) (maxParallel / tickTimeAfterOC), 0);
+ }
+ int maxParallelBeforeBatchMode = maxParallel;
+ if (isBatchModeEnabled()) {
+ maxParallel = GT_Utility.safeInt((long) maxParallel * getMaxBatchSize(), 0);
+ }
+
+ int currentParallel = (int) Math.min(maxParallel, availableEUt / RECIPE_EUT);
+ // Calculate parallel by fluids
int tLube = 0;
int tWater = 0;
-
for (FluidStack fluid : tInputFluid) {
if (fluid != null && fluid.equals(GT_ModHandler.getDistilledWater(1L))) {
tWater += fluid.amount;
@@ -286,15 +298,15 @@ public class GT_MetaTileEntity_IntegratedOreFactory extends
tLube += fluid.amount;
}
}
+ currentParallel = Math.min(currentParallel, tLube / 2);
+ currentParallel = Math.min(currentParallel, tWater / 200);
+ if (currentParallel <= 0) {
+ return CheckRecipeResultRegistry.NO_RECIPE;
+ }
- tCharged = Math.min(tCharged, tLube / 2);
- tCharged = Math.min(tCharged, tWater / 200);
-
- List<ItemStack> tOres = new ArrayList<>();
- int tRealUsed = 0;
-
+ // Calculate parallel by items
+ int itemParallel = 0;
for (ItemStack ore : tInput) {
- if (tCharged <= 0) break;
int tID = GT_Utility.stackToInt(ore);
if (tID == 0) continue;
if (isPureDust.contains(tID) || isImpureDust.contains(tID)
@@ -302,33 +314,61 @@ public class GT_MetaTileEntity_IntegratedOreFactory extends
|| isThermal.contains(tID)
|| isCrushedOre.contains(tID)
|| isOre.contains(tID)) {
- if (ore.stackSize <= tCharged) {
- tRealUsed += ore.stackSize;
- tOres.add(GT_Utility.copy(ore));
- tCharged -= ore.stackSize;
- ore.stackSize = 0;
+ if (itemParallel + ore.stackSize <= currentParallel) {
+ itemParallel += ore.stackSize;
} else {
- tRealUsed = tCharged;
- tOres.add(GT_Utility.copyAmountUnsafe(tCharged, ore));
- ore.stackSize -= tCharged;
- tCharged = 0;
+ itemParallel = currentParallel;
break;
}
}
}
+ currentParallel = itemParallel;
+ int currentParallelBeforeBatchMode = Math.min(currentParallel, maxParallelBeforeBatchMode);
+
+ long eutUseAfterOC = calculator
+ .calculateEUtConsumptionUnderOneTick(originalMaxParallel, currentParallelBeforeBatchMode);
+ calculator.setParallel(Math.min(currentParallelBeforeBatchMode, originalMaxParallel))
+ .calculate();
+
+ double batchMultiplierMax = 1;
+ // In case batch mode enabled
+ if (currentParallel > maxParallelBeforeBatchMode && calculator.getDuration() < getMaxBatchSize()) {
+ batchMultiplierMax = (double) getMaxBatchSize() / calculator.getDuration();
+ batchMultiplierMax = Math.min(batchMultiplierMax, (double) currentParallel / maxParallelBeforeBatchMode);
+ }
- // for scanner
- setCurrentParallelism(tRealUsed);
+ int finalParallel = (int) (batchMultiplierMax * maxParallelBeforeBatchMode);
- if (tRealUsed == 0) {
- return CheckRecipeResultRegistry.NO_RECIPE;
- }
+ // for scanner
+ setCurrentParallelism(finalParallel);
- depleteInput(GT_ModHandler.getDistilledWater(tRealUsed * 200L));
- depleteInput(Materials.Lubricant.getFluid(tRealUsed * 2L));
+ // Consume fluids
+ depleteInput(GT_ModHandler.getDistilledWater(finalParallel * 200L));
+ depleteInput(Materials.Lubricant.getFluid(finalParallel * 2L));
+ // Consume items and generate outputs
+ List<ItemStack> tOres = new ArrayList<>();
+ int remainingCost = finalParallel;
+ for (ItemStack ore : tInput) {
+ int tID = GT_Utility.stackToInt(ore);
+ if (tID == 0) continue;
+ if (isPureDust.contains(tID) || isImpureDust.contains(tID)
+ || isCrushedPureOre.contains(tID)
+ || isThermal.contains(tID)
+ || isCrushedOre.contains(tID)
+ || isOre.contains(tID)) {
+ if (remainingCost >= ore.stackSize) {
+ tOres.add(GT_Utility.copy(ore));
+ remainingCost -= ore.stackSize;
+ ore.stackSize = 0;
+ } else {
+ tOres.add(GT_Utility.copyAmountUnsafe(remainingCost, ore));
+ ore.stackSize -= remainingCost;
+ break;
+ }
+ }
+ }
sMidProduct = tOres.toArray(new ItemStack[0]);
-
switch (sMode) {
case 0 -> {
doMac(isOre);
@@ -363,12 +403,13 @@ public class GT_MetaTileEntity_IntegratedOreFactory extends
}
}
- this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
+ this.mEfficiency = 10000 - (getIdealStatus() - getRepairStatus()) * 1000;
this.mEfficiencyIncrease = 10000;
this.mOutputItems = sMidProduct;
- calculateOverclockedNessMultiInternal(30L * tRealUsed, getTime(sMode), 1, getMaxInputVoltage(), false);
- if (this.mEUt > 0) {
- this.mEUt = -this.mEUt;
+ this.mMaxProgresstime = (int) (calculator.getDuration() * batchMultiplierMax);
+ this.lEUt = eutUseAfterOC;
+ if (this.lEUt > 0) {
+ this.lEUt = -this.lEUt;
}
this.updateSlots();
@@ -782,4 +823,9 @@ public class GT_MetaTileEntity_IntegratedOreFactory extends
tag.setBoolean("ssStone", sVoidStone);
tag.setInteger("currentParallelism", currentParallelism);
}
+
+ @Override
+ public boolean supportsBatchMode() {
+ return true;
+ }
}
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java
index 4f24b769d0..0dba58092e 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java
@@ -45,6 +45,7 @@ import gregtech.api.recipe.check.CheckRecipeResultRegistry;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
+import gregtech.api.util.GT_OverclockCalculator;
import gregtech.api.util.GT_StructureUtility;
import gregtech.api.util.GT_Utility;
@@ -54,6 +55,8 @@ public class GT_MetaTileEntity_MultiFurnace
private int mLevel = 0;
private int mCostDiscount = 1;
+ private static final long RECIPE_EUT = 4;
+ private static final int RECIPE_DURATION = 512;
private static final int CASING_INDEX = 11;
private static final String STRUCTURE_PIECE_MAIN = "main";
private static final IStructureDefinition<GT_MetaTileEntity_MultiFurnace> STRUCTURE_DEFINITION = StructureDefinition
@@ -153,50 +156,84 @@ public class GT_MetaTileEntity_MultiFurnace
ArrayList<ItemStack> tInputList = getAllStoredInputs();
if (tInputList.isEmpty()) return CheckRecipeResultRegistry.NO_RECIPE;
- int mVolatage = GT_Utility.safeInt(getMaxInputVoltage());
- int tMaxParallel = this.mLevel;
+ int mVoltage = GT_Utility.safeInt(getMaxInputVoltage());
+
+ GT_OverclockCalculator calculator = new GT_OverclockCalculator().setEUt(mVoltage)
+ .setRecipeEUt(RECIPE_EUT)
+ .setDuration(RECIPE_DURATION);
+ int maxParallel = this.mLevel;
+ int originalMaxParallel = maxParallel;
+ double tickTimeAfterOC = calculator.calculateDurationUnderOneTick();
+ if (tickTimeAfterOC < 1) {
+ maxParallel = GT_Utility.safeInt((long) (maxParallel / tickTimeAfterOC), 0);
+ }
+
+ int maxParallelBeforeBatchMode = maxParallel;
+ if (isBatchModeEnabled()) {
+ maxParallel = GT_Utility.safeInt((long) maxParallel * getMaxBatchSize(), 0);
+ }
+
+ // Calculate parallel
int tCurrentParallel = 0;
- ArrayList<ItemStack> smeltedOutputs = new ArrayList<>();
- ArrayList<Integer> outputStackSizes = new ArrayList<>();
for (ItemStack item : tInputList) {
ItemStack smeltedOutput = GT_ModHandler.getSmeltingOutput(item, false, null);
if (smeltedOutput != null) {
- smeltedOutputs.add(smeltedOutput);
- if (item.stackSize <= (tMaxParallel - tCurrentParallel)) {
+ if (item.stackSize <= (maxParallel - tCurrentParallel)) {
tCurrentParallel += item.stackSize;
- outputStackSizes.add(smeltedOutput.stackSize * item.stackSize);
- item.stackSize = 0;
} else {
- int remainingStackSize = tCurrentParallel + item.stackSize - tMaxParallel;
- outputStackSizes.add(smeltedOutput.stackSize * (item.stackSize - remainingStackSize));
- item.stackSize = remainingStackSize;
+ tCurrentParallel = maxParallel;
break;
}
}
- if (tCurrentParallel == tMaxParallel) {
- break;
- }
}
- this.mOutputItems = new ItemStack[smeltedOutputs.size()];
- for (int i = 0; i < this.mOutputItems.length; i++) {
- ItemStack tNewStack = smeltedOutputs.get(i);
- tNewStack.stackSize = outputStackSizes.get(i);
- this.mOutputItems[i] = tNewStack;
+ if (tCurrentParallel <= 0) {
+ return CheckRecipeResultRegistry.NO_RECIPE;
+ }
+ int currentParallelBeforeBatchMode = Math.min(tCurrentParallel, maxParallelBeforeBatchMode);
+
+ long eutUseAfterOC = calculator.calculateEUtConsumptionUnderOneTick(
+ 1,
+ (int) Math.ceil((double) currentParallelBeforeBatchMode / originalMaxParallel));
+ calculator
+ .setParallel(Math.min((int) Math.ceil((double) currentParallelBeforeBatchMode / originalMaxParallel), 1))
+ .calculate();
+
+ double batchMultiplierMax = 1;
+ // In case batch mode enabled
+ if (tCurrentParallel > maxParallelBeforeBatchMode && calculator.getDuration() < getMaxBatchSize()) {
+ batchMultiplierMax = (double) getMaxBatchSize() / calculator.getDuration();
+ batchMultiplierMax = Math.min(batchMultiplierMax, (double) tCurrentParallel / maxParallelBeforeBatchMode);
}
+ int finalParallel = (int) (batchMultiplierMax * maxParallelBeforeBatchMode);
- if (this.mOutputItems.length > 0) {
- this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
- this.mEfficiencyIncrease = 10000;
- calculateOverclockedNessMultiInternal(4, 512, 1, mVolatage, false);
- // In case recipe is too OP for that machine
- if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1)
- return CheckRecipeResultRegistry.NO_RECIPE;
+ // Consume inputs and generate outputs
+ ArrayList<ItemStack> smeltedOutputs = new ArrayList<>();
+ int remainingCost = finalParallel;
+ for (ItemStack item : tInputList) {
+ ItemStack smeltedOutput = GT_ModHandler.getSmeltingOutput(item, false, null);
+ if (smeltedOutput != null) {
+ if (remainingCost >= item.stackSize) {
+ remainingCost -= item.stackSize;
+ smeltedOutput.stackSize *= item.stackSize;
+ item.stackSize = 0;
+ smeltedOutputs.add(smeltedOutput);
+ } else {
+ smeltedOutput.stackSize *= remainingCost;
+ item.stackSize -= remainingCost;
+ smeltedOutputs.add(smeltedOutput);
+ break;
+ }
+ }
+ }
+ this.mOutputItems = smeltedOutputs.toArray(new ItemStack[0]);
- this.mEUt = GT_Utility.safeInt(((long) mEUt) * (this.mLevel / 8) / (long) this.mCostDiscount, 1);
- if (mEUt == Integer.MAX_VALUE - 1) return CheckRecipeResultRegistry.NO_RECIPE;
+ this.mEfficiency = 10000 - (getIdealStatus() - getRepairStatus()) * 1000;
+ this.mEfficiencyIncrease = 10000;
+ this.mMaxProgresstime = (int) (calculator.getDuration() * batchMultiplierMax);
+ this.lEUt = eutUseAfterOC;
+
+ if (this.lEUt > 0) this.lEUt = -this.lEUt;
- if (this.mEUt > 0) this.mEUt = (-this.mEUt);
- }
updateSlots();
return CheckRecipeResultRegistry.SUCCESSFUL;
}
@@ -332,4 +369,9 @@ public class GT_MetaTileEntity_MultiFurnace
if (mMachine) return -1;
return survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 1, 2, 0, elementBudget, env, false, true);
}
+
+ @Override
+ public boolean supportsBatchMode() {
+ return true;
+ }
}