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) {
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
}
}
}

View file

@ -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
}
}
}

View file

@ -41,25 +41,30 @@ public class GT_MetaTileEntity_Disassembler
if (getBaseMetaTileEntity().getRandomNumber(100) < 50 + 10 * this.mTier) {
this.mOutputItems[i] = GT_Utility.loadItem(tNBT, "Ingredient." + i);
if (this.mOutputItems[i] != null) {
this.mMaxProgresstime *= (mTier>5 ? 1.7F-(mTier/10.0F) : 1.7F);
this.mMaxProgresstime *= 1.7F;
isAnyOutput=true;
}
}
}
if(!isAnyOutput){
return 0;
if(!isAnyOutput)
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;
return 2;
return FOUND_AND_SUCCESSFULLY_USED_RECIPE;
}
}
}
return 0;
return DID_NOT_FIND_RECIPE;
}
private void calculateOverclockedNessDisassembler(int aEUt) {
if(mTier==0){
mEUt=aEUt/4;
mEUt=aEUt>>2;
}else{
//Long EUt calculation
long xEUt=aEUt;
@ -67,14 +72,15 @@ public class GT_MetaTileEntity_Disassembler
long tempEUt = xEUt<GT_Values.V[1] ? GT_Values.V[1] : xEUt;
while (tempEUt <= GT_Values.V[mTier -1] * (long)mAmperage) {
tempEUt *= 4;//this actually controls overclocking
xEUt *= 4;//this is effect of overclocking
tempEUt<<=2;//this actually controls overclocking
xEUt<<=2;//this is effect of overclocking
}
if(xEUt>Integer.MAX_VALUE-1){
mEUt = Integer.MAX_VALUE-1;
}else{
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() {
if(mTier==0){
//Long time calculation
long xMaxProgresstime = (long)sDurationMultiplier*2L;
long xMaxProgresstime = ((long)sDurationMultiplier)<<1;
if(xMaxProgresstime>Integer.MAX_VALUE-1){
//make impossible if too long
mEUt=Integer.MAX_VALUE-1;
mMaxProgresstime=Integer.MAX_VALUE-1;
}else{
mEUt= (int)(GT_Values.V[1] * 4);
mEUt= (int)(GT_Values.V[1]<<2);//2^2=4 so shift <<2
mMaxProgresstime=(int)xMaxProgresstime;
}
}else{
//TODO: CHECK IF THAT WORKS
//Long EUt calculation
long xEUt=GT_Values.V[1] * (long)Math.pow(2,mTier+2);
@ -89,17 +88,20 @@ public class GT_MetaTileEntity_Massfabricator
mMaxProgresstime = sDurationMultiplier;
while (tempEUt <= V[mTier -1]) {
tempEUt *= 4;//this actually controls overclocking
mMaxProgresstime /= 2;//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
tempEUt<<=2;//this actually controls overclocking
mMaxProgresstime>>=1;//this is effect of overclocking
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){
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
}
}
}