diff options
Diffstat (limited to 'src/main/java')
2 files changed, 55 insertions, 59 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index 3efbe0d57b..c6828c707e 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -1,10 +1,5 @@ package gregtech.api.metatileentity.implementations; -import static gregtech.api.enums.GT_Values.V; -import static gregtech.api.enums.GT_Values.VN; - -import java.util.ArrayList; - import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; @@ -29,6 +24,11 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraftforge.fluids.FluidStack; +import java.util.ArrayList; + +import static gregtech.api.enums.GT_Values.V; +import static gregtech.api.enums.GT_Values.VN; + public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { public static boolean disableMaintenance; @@ -538,13 +538,6 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { aFirstVoltageFound = aVoltage; } else { - /** - * Calcualtes overclocked ness using long integers - * @param aEUt - recipe EUt - * @param aDuration - recipe Duration - * @param mAmperage - should be 1 ? - */ - //Long time calculation if (aFirstVoltageFound != aVoltage) { aFoundMixedDynamos = true; } @@ -559,13 +552,10 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } long leftToInject; - //Long EUt calculation long aVoltage; - //Isnt too low EUt check? int aAmpsToInject; int aRemainder; int ampsOnCurrentHatch; - //xEUt *= 4;//this is effect of everclocking for (GT_MetaTileEntity_Hatch_Dynamo aDynamo : mDynamoHatches) { if (isValidMetaTileEntity(aDynamo)) { leftToInject = aEU - injected; @@ -594,51 +584,63 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } /** - * Calcualtes overclocked ness using long integers - * @param aEUt - recipe EUt - * @param aDuration - recipe Duration - * @param mAmperage - should be 1 ? + * Calcualtes the overclockedness using long integers + * @param aEUt - recipe EUt + * @param aDuration - recipe Duration + * @param mAmperage - should be 1 ? + * @param maxInputVoltage - Multiblock Max input voltage + * @param perfectOC - If the Multiblock OCs perfectly, i.e. the large Chemical Reactor */ - protected void calculateOverclockedNessMulti(int aEUt, int aDuration, int mAmperage, long maxInputVoltage) { - byte mTier=(byte)Math.max(0,GT_Utility.getTier(maxInputVoltage)); - if(mTier==0){ + protected void calculateOverclockedNessMultiInternal(int aEUt, int aDuration, int mAmperage, long maxInputVoltage, boolean perfectOC) { + byte mTier = (byte) Math.max(0, GT_Utility.getTier(maxInputVoltage)); + if(mTier == 0){ //Long time calculation long xMaxProgresstime = ((long)aDuration)<<1; - if(xMaxProgresstime>Integer.MAX_VALUE-1){ + if(xMaxProgresstime > Integer.MAX_VALUE - 1){ //make impossible if too long - mEUt=Integer.MAX_VALUE-1; - mMaxProgresstime=Integer.MAX_VALUE-1; + mEUt = Integer.MAX_VALUE - 1; + mMaxProgresstime = Integer.MAX_VALUE - 1; }else{ - mEUt=aEUt>>2; - mMaxProgresstime=(int)xMaxProgresstime; + mEUt = aEUt >> 2; + mMaxProgresstime= (int) xMaxProgresstime; } }else{ //Long EUt calculation - long xEUt=aEUt; + long xEUt = aEUt; //Isnt too low EUt check? - long tempEUt = xEUt<V[1] ? V[1] : xEUt; + long tempEUt = Math.max(xEUt, V[1]); mMaxProgresstime = aDuration; - while (tempEUt <= V[mTier -1] * mAmperage) { - tempEUt<<=2;//this actually controls overclocking + final int ocTimeShift = perfectOC ? 2 : 1; + + while (tempEUt <= V[mTier - 1] * mAmperage) { + tempEUt <<= 2;//this actually controls overclocking //xEUt *= 4;//this is effect of everclocking - mMaxProgresstime>>=1;//this is effect of overclocking - xEUt = mMaxProgresstime==0 ? xEUt>>1 : xEUt<<2;//U know, if the time is less than 1 tick make the machine use less power + mMaxProgresstime >>= ocTimeShift;//this is effect of overclocking + xEUt = mMaxProgresstime==0 ? xEUt >> ocTimeShift : xEUt << 2;//U know, if the time is less than 1 tick make the machine use less power } - if(xEUt>Integer.MAX_VALUE-1){ - mEUt = Integer.MAX_VALUE-1; - mMaxProgresstime = Integer.MAX_VALUE-1; - }else{ - mEUt = (int)xEUt; - if(mEUt==0) + if(xEUt > Integer.MAX_VALUE - 1) { + mEUt = Integer.MAX_VALUE - 1; + mMaxProgresstime = Integer.MAX_VALUE - 1; + } else { + mEUt = (int) xEUt; + if(mEUt == 0) mEUt = 1; - if(mMaxProgresstime==0) + if(mMaxProgresstime == 0) mMaxProgresstime = 1;//set time to 1 tick } } } + protected void calculateOverclockedNessMulti(int aEUt, int aDuration, int mAmperage, long maxInputVoltage) { + calculateOverclockedNessMultiInternal(aEUt,aDuration,mAmperage,maxInputVoltage,false); + } + + protected void calculatePerfectOverclockedNessMulti(int aEUt, int aDuration, int mAmperage, long maxInputVoltage) { + calculateOverclockedNessMultiInternal(aEUt,aDuration,mAmperage,maxInputVoltage,true); + } + public boolean drainEnergyInput(long aEU) { if (aEU <= 0) return true; for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java index 42b8a51153..13764b928e 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java @@ -115,30 +115,24 @@ public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_Mu FluidStack[] fluids = tFluidList.toArray(new FluidStack[tFluidList.size()]); if (inputs.length > 0 || fluids.length > 0) { - long voltage = getMaxInputVoltage(); - byte tier = (byte) Math.max(1, GT_Utility.getTier(voltage)); - GT_Recipe recipe = GT_Recipe.GT_Recipe_Map.sMultiblockChemicalRecipes.findRecipe(getBaseMetaTileEntity(), false, + long tVoltage = getMaxInputVoltage(); + byte tier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sMultiblockChemicalRecipes.findRecipe(getBaseMetaTileEntity(), false, false, gregtech.api.enums.GT_Values.V[tier], fluids, inputs); - if (recipe != null && recipe.isRecipeInputEqual(true, fluids, inputs)) { + if (tRecipe != null && tRecipe.isRecipeInputEqual(true, fluids, inputs)) { this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; - int EUt = recipe.mEUt; - int maxProgresstime = recipe.mDuration; - - while (EUt <= gregtech.api.enums.GT_Values.V[tier - 1] && maxProgresstime > 2) { - EUt *= 4; - maxProgresstime /= 4; - } - if (maxProgresstime < 2) { - maxProgresstime = 2; - EUt = recipe.mEUt * recipe.mDuration / 2; + calculatePerfectOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, 1, tVoltage); + //In case recipe is too OP for that machine + if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) + return false; + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); } - - this.mEUt = -EUt; - this.mMaxProgresstime = maxProgresstime; - this.mOutputItems = recipe.mOutputs; - this.mOutputFluids = recipe.mFluidOutputs; + + this.mOutputItems = tRecipe.mOutputs; + this.mOutputFluids = tRecipe.mFluidOutputs; this.updateSlots(); return true; } |