diff options
author | Technus <daniel112092@gmail.com> | 2016-10-24 18:11:15 +0200 |
---|---|---|
committer | Technus <daniel112092@gmail.com> | 2016-10-24 18:11:15 +0200 |
commit | 9ecccffd9436d9684311820b184e35d5328415da (patch) | |
tree | 9ffc73d2ab6ba8c429bc0ec8a176d2e89a44d2f2 /src/main/java/gregtech/api/metatileentity | |
parent | ef5a72fa51fd8d192b06cc410f6c8f21343369e7 (diff) | |
download | GT5-Unofficial-9ecccffd9436d9684311820b184e35d5328415da.tar.gz GT5-Unofficial-9ecccffd9436d9684311820b184e35d5328415da.tar.bz2 GT5-Unofficial-9ecccffd9436d9684311820b184e35d5328415da.zip |
Optimized overclockedness
Diffstat (limited to 'src/main/java/gregtech/api/metatileentity')
2 files changed, 18 insertions, 14 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java index 60cb3c4564..c68ea4a612 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java @@ -533,13 +533,13 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B protected void calculateOverclockedNess(int aEUt, int aDuration) { if(mTier==0){ //Long time calculation - long xMaxProgresstime = (long)aDuration*2L; + long xMaxProgresstime = ((long)aDuration)<<1; 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; + mEUt=aEUt>>2; mMaxProgresstime=(int)xMaxProgresstime; } }else{ @@ -551,18 +551,20 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B mMaxProgresstime = aDuration; while (tempEUt <= V[mTier -1] * (long)mAmperage) { - tempEUt *= 4;//this actually controls overclocking + tempEUt<<=2;//this actually controls overclocking //xEUt *= 4;//this is effect of everclocking - mMaxProgresstime /= 2;//this is effect of overclocking - xEUt = mMaxProgresstime==0 ? (long)(xEUt/1.1D) : xEUt*4;//U know, if the time is less than 1 tick make the machine use 2x less power + 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 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 + if(mEUt==0) + mEUt = 1; + if(mMaxProgresstime==0) + mMaxProgresstime = 1;//set time to 1 tick } } } 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 5b8a82326b..97cbe95255 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 @@ -524,13 +524,13 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { byte mTier=(byte)Math.max(0,GT_Utility.getTier(maxInputVoltage)); if(mTier==0){ //Long time calculation - long xMaxProgresstime = (long)aDuration*2L; + long xMaxProgresstime = ((long)aDuration)<<1; 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; + mEUt=aEUt>>2; mMaxProgresstime=(int)xMaxProgresstime; } }else{ @@ -542,18 +542,20 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { mMaxProgresstime = aDuration; while (tempEUt <= V[mTier -1] * mAmperage) { - tempEUt *= 4;//this actually controls overclocking + tempEUt<<=2;//this actually controls overclocking //xEUt *= 4;//this is effect of everclocking - mMaxProgresstime /= 2;//this is effect of overclocking - xEUt = mMaxProgresstime==0 ? (long)(xEUt/1.1D) : xEUt*4;//U know, if the time is less than 1 tick make the machine use less power + 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 } 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 + if(mEUt==0) + mEUt = 1; + if(mMaxProgresstime==0) + mMaxProgresstime = 1;//set time to 1 tick } } } |