adding method to multibocks

This commit is contained in:
Technus 2016-09-06 10:35:38 +02:00
parent 81dc8a48b1
commit 222e8ee267

View file

@ -14,6 +14,7 @@ import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.objects.GT_ItemStack;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
import gregtech.api.util.GT_Utility;
import gregtech.common.items.GT_MetaGenerated_Tool_01;
@ -512,6 +513,50 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
return rVoltage;
}
/**
* Calcualtes overclocked ness using long integers
* @param aEUt - recipe EUt
* @param aDuration - recipe Duration
* @param mAmperage - should be 1 ?
*/
protected void calculateOverclockedNessMulti(int aEUt, int aDuration, int mAmperage) {
byte mTier=GT_Utility.getTier(getMaxInputVoltage());
if(mTier==0){
//Long time calculation
long xMaxProgresstime = (long)aDuration*2L;
if(xMaxProgresstime>Integer.MAX_VALUE-1){
//make impossible if too long
mEUt=Integer.MAX_VALUE-1;
mMaxProgresstime=Integer.MAX_VALUE-1;
}else{
mEUt=aEUt/4;
mMaxProgresstime=(int)xMaxProgresstime;
}
}else{
//Long EUt calculation
long xEUt=aEUt;
//Isnt too low EUt check?
long tempEUt = xEUt<V[1] ? V[1] : xEUt;
mMaxProgresstime = aDuration;
while (tempEUt <= V[mTier -1] * (long)mAmperage) {
tempEUt *= 4;//this actually controls overclocking
xEUt *= 4;//this is effect of everclocking
mMaxProgresstime /= 2;//this is effect of overclocking
xEUt = mMaxProgresstime==0 ? xEUt/2 : xEUt;//U know, if the time is less than 1 tick make the machine use 2x less power
}
if(xEUt>Integer.MAX_VALUE-1){
mEUt = Integer.MAX_VALUE-1;
mMaxProgresstime = Integer.MAX_VALUE-1;
}else{
mEUt = (int)xEUt;
mEUt = mEUt == 0 ? 1 : mEUt;
mMaxProgresstime = mMaxProgresstime<1 ? 1 : mMaxProgresstime;//set time to 1 tick
}
}
}
public boolean drainEnergyInput(long aEU) {
if (aEU <= 0) return true;
for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches)