Skip to content

Commit

Permalink
Check dynamo hatch (#85)
Browse files Browse the repository at this point in the history
* Update GT_MetaTileEntity_MultiBlockBase.java

Проверка динамо хэтча на превышение напряжения для взрыва для всех мультиблоковых генераторов.

* Update GT_MetaTileEntity_LargeTurbine.java
  • Loading branch information
Pilad authored Apr 15, 2020
1 parent 288b320 commit aa8a38d
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -505,15 +505,76 @@ public void explodeMultiblock() {
}

public boolean addEnergyOutput(long aEU) {
if (aEU <= 0) return true;
for (GT_MetaTileEntity_Hatch_Dynamo tHatch : mDynamoHatches) {
if (isValidMetaTileEntity(tHatch)) {
if (tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(aEU, false)) {
return true;
if (aEU <= 0) {
return true;
}
if (mDynamoHatches.size() > 0) {
return addEnergyOutputMultipleDynamos(aEU, true);
}
return false;
}
public boolean addEnergyOutputMultipleDynamos(long aEU, boolean aAllowMixedVoltageDynamos) {
int injected = 0;
long totalOutput = 0;
long aFirstVoltageFound = -1;
boolean aFoundMixedDynamos = false;
for (GT_MetaTileEntity_Hatch_Dynamo aDynamo : mDynamoHatches) {
if( aDynamo == null ) {
return false;
}
if (isValidMetaTileEntity(aDynamo)) {
long aVoltage = aDynamo.maxEUOutput();
long aTotal = aDynamo.maxAmperesOut() * aVoltage;
// Check against voltage to check when hatch mixing
if (aFirstVoltageFound == -1) {
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;
}
}
totalOutput += aTotal;
}
}
return false;
if (totalOutput < aEU || (aFoundMixedDynamos && !aAllowMixedVoltageDynamos)) {
explodeMultiblock();
return false;
}

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;
aVoltage = aDynamo.maxEUOutput();
aAmpsToInject = (int) (leftToInject / aVoltage);
aRemainder = (int) (leftToInject - (aAmpsToInject * aVoltage));
ampsOnCurrentHatch= (int) Math.min(aDynamo.maxAmperesOut(), aAmpsToInject);
for (int i = 0; i < ampsOnCurrentHatch; i++) {
aDynamo.getBaseMetaTileEntity().increaseStoredEnergyUnits(aVoltage, false);
}
injected+=aVoltage*ampsOnCurrentHatch;
if(aRemainder>0 && ampsOnCurrentHatch<aDynamo.maxAmperesOut()){
aDynamo.getBaseMetaTileEntity().increaseStoredEnergyUnits(aRemainder, false);
injected+=aRemainder;
}
}
}
return injected > 0;
}

public long getMaxInputVoltage() {
Expand Down Expand Up @@ -843,4 +904,4 @@ public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aInde
public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,7 @@ public boolean checkRecipe(ItemStack aStack) {
return false;
} else {
this.mMaxProgresstime = 1;
this.mEfficiencyIncrease = (10);
if(this.mDynamoHatches.size()>0){
if(this.mDynamoHatches.get(0).getBaseMetaTileEntity().getOutputVoltage() < (int)((long)mEUt * (long)mEfficiency / 10000L)){
explodeMultiblock();}
}
this.mEfficiencyIncrease = (10);
return true;
}
}
Expand Down

0 comments on commit aa8a38d

Please sign in to comment.