aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kubatech/api/helpers/GTHelper.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/kubatech/api/helpers/GTHelper.java')
-rw-r--r--src/main/java/kubatech/api/helpers/GTHelper.java40
1 files changed, 3 insertions, 37 deletions
diff --git a/src/main/java/kubatech/api/helpers/GTHelper.java b/src/main/java/kubatech/api/helpers/GTHelper.java
index 05d8bfb919..782c697232 100644
--- a/src/main/java/kubatech/api/helpers/GTHelper.java
+++ b/src/main/java/kubatech/api/helpers/GTHelper.java
@@ -1,50 +1,16 @@
package kubatech.api.helpers;
import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity;
+import static kubatech.api.Variables.ln4;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
-import java.util.ArrayList;
-import java.util.Arrays;
-import net.minecraft.item.ItemStack;
-import net.minecraftforge.fluids.FluidStack;
+import kubatech.api.implementations.KubaTechGTMultiBlockBase;
public class GTHelper {
- private static final double ln4 = Math.log(4d);
-
- public static int calculateOverclockedNessMulti(
- GT_MetaTileEntity_MultiBlockBase mte, long aEUt, int aDuration, boolean perfect) {
- final long maxInputVoltage = getMaxInputEU(mte);
- final int tiers = (int) (Math.log((double) maxInputVoltage / (double) aEUt) / ln4);
- if (tiers <= 0) {
- mte.mEUt = (int) aEUt;
- mte.mMaxProgresstime = aDuration;
- return 0;
- }
- mte.mEUt = (int) (aEUt << (tiers << 1));
- int dMulti = 1;
- final int aDurationModifier = perfect ? 2 : 1;
- for (int i = 0; i < tiers; i++)
- if (aDuration > 1) aDuration >>= aDurationModifier;
- else dMulti <<= aDurationModifier;
- if (dMulti > 1) {
- final ArrayList<ItemStack> stacks = new ArrayList<>(Arrays.asList(mte.mOutputItems));
- for (ItemStack mOutputItem : mte.mOutputItems) {
- mOutputItem.stackSize *= dMulti;
- int maxSize = mOutputItem.getMaxStackSize();
- while (mOutputItem.stackSize > maxSize)
- stacks.add(mOutputItem.splitStack(Math.min(mOutputItem.stackSize - maxSize, maxSize)));
- }
- if (stacks.size() != mte.mOutputItems.length) mte.mOutputItems = stacks.toArray(new ItemStack[0]);
- for (FluidStack mOutputFluid : mte.mOutputFluids) mOutputFluid.amount *= dMulti;
- }
- if (aDuration <= 0) aDuration = 1;
- mte.mMaxProgresstime = aDuration;
- return tiers;
- }
-
public static long getMaxInputEU(GT_MetaTileEntity_MultiBlockBase mte) {
+ if (mte instanceof KubaTechGTMultiBlockBase) return ((KubaTechGTMultiBlockBase<?>) mte).getMaxInputEu();
long rEU = 0;
for (GT_MetaTileEntity_Hatch_Energy tHatch : mte.mEnergyHatches)
if (isValidMetaTileEntity(tHatch)) rEU += tHatch.maxEUInput() * tHatch.maxAmperesIn();