Optimized overclockedness

This commit is contained in:
Technus 2016-10-24 18:11:15 +02:00
parent ef5a72fa51
commit 9ecccffd94
4 changed files with 43 additions and 31 deletions

View file

@ -533,13 +533,13 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
protected void calculateOverclockedNess(int aEUt, int aDuration) { protected void calculateOverclockedNess(int aEUt, int aDuration) {
if(mTier==0){ if(mTier==0){
//Long time calculation //Long time calculation
long xMaxProgresstime = (long)aDuration*2L; long xMaxProgresstime = ((long)aDuration)<<1;
if(xMaxProgresstime>Integer.MAX_VALUE-1){ if(xMaxProgresstime>Integer.MAX_VALUE-1){
//make impossible if too long //make impossible if too long
mEUt=Integer.MAX_VALUE-1; mEUt=Integer.MAX_VALUE-1;
mMaxProgresstime=Integer.MAX_VALUE-1; mMaxProgresstime=Integer.MAX_VALUE-1;
}else{ }else{
mEUt=aEUt/4; mEUt=aEUt>>2;
mMaxProgresstime=(int)xMaxProgresstime; mMaxProgresstime=(int)xMaxProgresstime;
} }
}else{ }else{
@ -551,18 +551,20 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
mMaxProgresstime = aDuration; mMaxProgresstime = aDuration;
while (tempEUt <= V[mTier -1] * (long)mAmperage) { 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 //xEUt *= 4;//this is effect of everclocking
mMaxProgresstime /= 2;//this is effect of overclocking mMaxProgresstime>>=1;//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 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){ if(xEUt>Integer.MAX_VALUE-1){
mEUt = Integer.MAX_VALUE-1; mEUt = Integer.MAX_VALUE-1;
mMaxProgresstime = Integer.MAX_VALUE-1; mMaxProgresstime = Integer.MAX_VALUE-1;
}else{ }else{
mEUt = (int)xEUt; mEUt = (int)xEUt;
mEUt = mEUt == 0 ? 1 : mEUt; if(mEUt==0)
mMaxProgresstime = mMaxProgresstime<1 ? 1 : mMaxProgresstime;//set time to 1 tick mEUt = 1;
if(mMaxProgresstime==0)
mMaxProgresstime = 1;//set time to 1 tick
} }
} }
} }

View file

@ -524,13 +524,13 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
byte mTier=(byte)Math.max(0,GT_Utility.getTier(maxInputVoltage)); byte mTier=(byte)Math.max(0,GT_Utility.getTier(maxInputVoltage));
if(mTier==0){ if(mTier==0){
//Long time calculation //Long time calculation
long xMaxProgresstime = (long)aDuration*2L; long xMaxProgresstime = ((long)aDuration)<<1;
if(xMaxProgresstime>Integer.MAX_VALUE-1){ if(xMaxProgresstime>Integer.MAX_VALUE-1){
//make impossible if too long //make impossible if too long
mEUt=Integer.MAX_VALUE-1; mEUt=Integer.MAX_VALUE-1;
mMaxProgresstime=Integer.MAX_VALUE-1; mMaxProgresstime=Integer.MAX_VALUE-1;
}else{ }else{
mEUt=aEUt/4; mEUt=aEUt>>2;
mMaxProgresstime=(int)xMaxProgresstime; mMaxProgresstime=(int)xMaxProgresstime;
} }
}else{ }else{
@ -542,18 +542,20 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
mMaxProgresstime = aDuration; mMaxProgresstime = aDuration;
while (tempEUt <= V[mTier -1] * mAmperage) { 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 //xEUt *= 4;//this is effect of everclocking
mMaxProgresstime /= 2;//this is effect of overclocking mMaxProgresstime>>=1;//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 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){ if(xEUt>Integer.MAX_VALUE-1){
mEUt = Integer.MAX_VALUE-1; mEUt = Integer.MAX_VALUE-1;
mMaxProgresstime = Integer.MAX_VALUE-1; mMaxProgresstime = Integer.MAX_VALUE-1;
}else{ }else{
mEUt = (int)xEUt; mEUt = (int)xEUt;
mEUt = mEUt == 0 ? 1 : mEUt; if(mEUt==0)
mMaxProgresstime = mMaxProgresstime<1 ? 1 : mMaxProgresstime;//set time to 1 tick mEUt = 1;
if(mMaxProgresstime==0)
mMaxProgresstime = 1;//set time to 1 tick
} }
} }
} }

View file

@ -41,25 +41,30 @@ public class GT_MetaTileEntity_Disassembler
if (getBaseMetaTileEntity().getRandomNumber(100) < 50 + 10 * this.mTier) { if (getBaseMetaTileEntity().getRandomNumber(100) < 50 + 10 * this.mTier) {
this.mOutputItems[i] = GT_Utility.loadItem(tNBT, "Ingredient." + i); this.mOutputItems[i] = GT_Utility.loadItem(tNBT, "Ingredient." + i);
if (this.mOutputItems[i] != null) { if (this.mOutputItems[i] != null) {
this.mMaxProgresstime *= (mTier>5 ? 1.7F-(mTier/10.0F) : 1.7F); this.mMaxProgresstime *= 1.7F;
isAnyOutput=true; isAnyOutput=true;
} }
} }
} }
if(!isAnyOutput){ if(!isAnyOutput)
return 0; return DID_NOT_FIND_RECIPE;
for(int i=mTier-5;i>0;i--){
this.mMaxProgresstime>>=1;
if(this.mMaxProgresstime==0)
this.mEUt = this.mEUt>>1;
} }
this.mMaxProgresstime = this.mMaxProgresstime==0 ? 1 : this.mMaxProgresstime;
getInputAt(0).stackSize -= 1; getInputAt(0).stackSize -= 1;
return 2; return FOUND_AND_SUCCESSFULLY_USED_RECIPE;
} }
} }
} }
return 0; return DID_NOT_FIND_RECIPE;
} }
private void calculateOverclockedNessDisassembler(int aEUt) { private void calculateOverclockedNessDisassembler(int aEUt) {
if(mTier==0){ if(mTier==0){
mEUt=aEUt/4; mEUt=aEUt>>2;
}else{ }else{
//Long EUt calculation //Long EUt calculation
long xEUt=aEUt; long xEUt=aEUt;
@ -67,14 +72,15 @@ public class GT_MetaTileEntity_Disassembler
long tempEUt = xEUt<GT_Values.V[1] ? GT_Values.V[1] : xEUt; long tempEUt = xEUt<GT_Values.V[1] ? GT_Values.V[1] : xEUt;
while (tempEUt <= GT_Values.V[mTier -1] * (long)mAmperage) { while (tempEUt <= GT_Values.V[mTier -1] * (long)mAmperage) {
tempEUt *= 4;//this actually controls overclocking tempEUt<<=2;//this actually controls overclocking
xEUt *= 4;//this is effect of overclocking xEUt<<=2;//this is effect of overclocking
} }
if(xEUt>Integer.MAX_VALUE-1){ if(xEUt>Integer.MAX_VALUE-1){
mEUt = Integer.MAX_VALUE-1; mEUt = Integer.MAX_VALUE-1;
}else{ }else{
mEUt = (int)xEUt; mEUt = (int)xEUt;
mEUt = mEUt == 0 ? 1 : mEUt; if(mEUt==0)
mEUt = 1;
} }
} }
} }

View file

@ -70,17 +70,16 @@ public class GT_MetaTileEntity_Massfabricator
private void calculateOverclockedNessMassFabricator() { private void calculateOverclockedNessMassFabricator() {
if(mTier==0){ if(mTier==0){
//Long time calculation //Long time calculation
long xMaxProgresstime = (long)sDurationMultiplier*2L; long xMaxProgresstime = ((long)sDurationMultiplier)<<1;
if(xMaxProgresstime>Integer.MAX_VALUE-1){ if(xMaxProgresstime>Integer.MAX_VALUE-1){
//make impossible if too long //make impossible if too long
mEUt=Integer.MAX_VALUE-1; mEUt=Integer.MAX_VALUE-1;
mMaxProgresstime=Integer.MAX_VALUE-1; mMaxProgresstime=Integer.MAX_VALUE-1;
}else{ }else{
mEUt= (int)(GT_Values.V[1] * 4); mEUt= (int)(GT_Values.V[1]<<2);//2^2=4 so shift <<2
mMaxProgresstime=(int)xMaxProgresstime; mMaxProgresstime=(int)xMaxProgresstime;
} }
}else{ }else{
//TODO: CHECK IF THAT WORKS
//Long EUt calculation //Long EUt calculation
long xEUt=GT_Values.V[1] * (long)Math.pow(2,mTier+2); long xEUt=GT_Values.V[1] * (long)Math.pow(2,mTier+2);
@ -89,17 +88,20 @@ public class GT_MetaTileEntity_Massfabricator
mMaxProgresstime = sDurationMultiplier; mMaxProgresstime = sDurationMultiplier;
while (tempEUt <= V[mTier -1]) { while (tempEUt <= V[mTier -1]) {
tempEUt *= 4;//this actually controls overclocking tempEUt<<=2;//this actually controls overclocking
mMaxProgresstime /= 2;//this is effect of overclocking mMaxProgresstime>>=1;//this is effect of overclocking
xEUt = mMaxProgresstime==0 ? (long)(xEUt/1.1D) : xEUt;//U know, if the time is less than 1 tick make the machine use less power if(mMaxProgresstime==0)
xEUt = (long)(xEUt/1.1D);//U know, if the time is less than 1 tick make the machine use less power
} }
if(xEUt>Integer.MAX_VALUE-1){ if(xEUt>Integer.MAX_VALUE-1){
mEUt = Integer.MAX_VALUE-1; mEUt = Integer.MAX_VALUE-1;
mMaxProgresstime = Integer.MAX_VALUE-1; mMaxProgresstime = Integer.MAX_VALUE-1;
}else{ }else{
mEUt = (int)xEUt; mEUt = (int)xEUt;
mEUt = mEUt == 0 ? 1 : mEUt; if(mEUt==0)
mMaxProgresstime = mMaxProgresstime<1 ? 1 : mMaxProgresstime;//set time to 1 tick mEUt = 1;
if(mMaxProgresstime==0)
mMaxProgresstime = 1;//set time to 1 tick
} }
} }
} }