Skip to content
This repository has been archived by the owner on May 25, 2024. It is now read-only.

Commit

Permalink
fix the fuel consuption bug
Browse files Browse the repository at this point in the history
  • Loading branch information
GlodBlock committed May 9, 2021
1 parent eeb6aa2 commit 9a06a9f
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 29 deletions.
96 changes: 68 additions & 28 deletions src/main/java/GoodGenerator/Blocks/TEs/MultiNqGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public class MultiNqGenerator extends GT_MetaTileEntity_MultiblockBase_EM implem
private IStructureDefinition<MultiNqGenerator> multiDefinition = null;
private int ticker = 0;
private int leftEnergy = 0;
boolean fluidLocker = true;
FluidStack lockedFluid = null;
int times = 1;

@Override
public void construct(ItemStack itemStack, boolean hintsOnly) {
Expand Down Expand Up @@ -175,9 +178,14 @@ public boolean checkRecipe_EM(ItemStack aStack) {
}
}

FluidStack f1=null,f2=null;
int cnt = 0;

for (GT_Recipe recipe : tRecipes) if (tFluids.contains(recipe.mFluidInputs[0])) cnt ++;

if (cnt > 1) doExplosion(4 * 4);

FluidStack f1=null;
float booster = 1.0f;
int times = 1;
if(tFluids.size() > 0){
if(tFluids.contains(FluidRegistry.getFluidStack("cryotheum", 50)) && tFluids.get(tFluids.indexOf(FluidRegistry.getFluidStack("cryotheum", 50))).amount >= 50){
booster = 2.75f;
Expand All @@ -193,26 +201,23 @@ else if(tFluids.contains(FluidRegistry.getFluidStack("ic2coolant",50)) && tFluid
}
}

if(tFluids.size() > 0){
if (tFluids.contains((MyMaterial.atomicSeparationCatalyst.getMolten(1))) && tFluids.get(tFluids.indexOf(MyMaterial.atomicSeparationCatalyst.getMolten(1))).amount >= 1){
times = 16;
f2=MyMaterial.atomicSeparationCatalyst.getMolten(1);
}
else if(tFluids.contains(Materials.Naquadah.getMolten(1L)) && tFluids.get(tFluids.indexOf(Materials.Naquadah.getMolten(1L))).amount >= 1){
times = 4;
f2=Materials.Naquadah.getMolten(1L);
}
else if(tFluids.contains(Materials.Uranium235.getMolten(9L)) && tFluids.get(tFluids.indexOf(Materials.Uranium235.getMolten(9L))).amount >= 9){
times = 3;
f2=Materials.Uranium235.getMolten(9L);
if (fluidLocker && lockedFluid != null){
if (!(tFluids.contains(lockedFluid) && tFluids.get(tFluids.indexOf(lockedFluid)).amount >= lockedFluid.amount)){
times = 1;
}
else if (tFluids.contains(Materials.Caesium.getMolten(9L)) && tFluids.get(tFluids.indexOf(Materials.Caesium.getMolten(9L))).amount >= 9){
times = 2;
f2=Materials.Caesium.getMolten(9L);
else {
if (lockedFluid.getFluid() == MyMaterial.atomicSeparationCatalyst.getMolten(1).getFluid())
times = 16;
else if (lockedFluid.getFluid() == Materials.Naquadah.getMolten(1L).getFluid())
times = 4;
else if (lockedFluid.getFluid() == Materials.Uranium235.getMolten(9L).getFluid())
times = 3;
else if (lockedFluid.getFluid() == Materials.Caesium.getMolten(9L).getFluid())
times = 2;
}
}

if (tFluids.size()>0 && tRecipes != null){
if (tFluids.size()>0){
for (GT_Recipe recipe : tRecipes){
FluidStack recipeFluid = recipe.mFluidInputs[0].copy();
FluidStack recipeFluidOut = recipe.mFluidOutputs[0].copy();
Expand All @@ -223,9 +228,35 @@ else if (tFluids.contains(Materials.Caesium.getMolten(9L)) && tFluids.get(tFluid
if (tFluids.contains(recipeFluid) && tFluids.get(tFluids.indexOf(recipeFluid)).amount >= times){
if(f1 != null)
depleteInput(f1);
if(f2 != null)
depleteInput(f2);
if(lockedFluid != null && times != 1)
depleteInput(lockedFluid);
if (ticker == 0 || ticker%lasting == 0){
fluidLocker = false;
if(tFluids.size() > 0){
if (tFluids.contains((MyMaterial.atomicSeparationCatalyst.getMolten(1))) && tFluids.get(tFluids.indexOf(MyMaterial.atomicSeparationCatalyst.getMolten(1))).amount >= 1){
times = 16;
lockedFluid = MyMaterial.atomicSeparationCatalyst.getMolten(1);
}
else if(tFluids.contains(Materials.Naquadah.getMolten(1L)) && tFluids.get(tFluids.indexOf(Materials.Naquadah.getMolten(1L))).amount >= 1){
times = 4;
lockedFluid = Materials.Naquadah.getMolten(1L);
}
else if(tFluids.contains(Materials.Uranium235.getMolten(9L)) && tFluids.get(tFluids.indexOf(Materials.Uranium235.getMolten(9L))).amount >= 9){
times = 3;
lockedFluid = Materials.Uranium235.getMolten(9L);
}
else if (tFluids.contains(Materials.Caesium.getMolten(9L)) && tFluids.get(tFluids.indexOf(Materials.Caesium.getMolten(9L))).amount >= 9){
times = 2;
lockedFluid = Materials.Caesium.getMolten(9L);
}
else {
times = 1;
lockedFluid = null;
}
fluidLocker = true;
recipeFluid.amount = times;
recipeFluidOut.amount = times;
}
depleteInput(recipeFluid);
this.mOutputFluids = new FluidStack[]{recipeFluidOut};
}
Expand Down Expand Up @@ -256,17 +287,22 @@ public void addAutoEnergy(long outputPower){
long power = voltage * tHatch.maxAmperesOut();
long outputAmperes;
if (outputPower > power) doExplosion(4 * GT_Utility.getTier(power));
leftEnergy += outputPower;
outputAmperes = leftEnergy / voltage;
leftEnergy -= outputAmperes * voltage;
addEnergyOutput_EM(voltage ,outputAmperes);
if (outputPower >= voltage){
leftEnergy += outputPower;
outputAmperes = leftEnergy / voltage;
leftEnergy -= outputAmperes * voltage;
addEnergyOutput_EM(voltage ,outputAmperes);
}
else{
addEnergyOutput_EM(outputPower, 1);
}
}
if (this.mDynamoHatches.size() > 0)
for (GT_MetaTileEntity_Hatch tHatch : this.mDynamoHatches){
long voltage = tHatch.maxEUOutput();
long power = voltage * tHatch.maxAmperesOut();
long outputAmperes;
if (outputPower > power) doExplosion(4 * GT_Utility.getTier(power));
if (outputPower > power) doExplosion(8 * GT_Utility.getTier(power));
leftEnergy += outputPower;
outputAmperes = leftEnergy / voltage;
leftEnergy -= outputAmperes * voltage;
Expand All @@ -280,12 +316,15 @@ public boolean onRunningTick(ItemStack stack) {
mRuntime ++;
ticker ++;
}
if (!getBaseMetaTileEntity().isActive()) {
if (!getBaseMetaTileEntity().isActive() || !getBaseMetaTileEntity().isAllowedToWork()) {
mRuntime = 0;
ticker = 0;
leftEnergy = 0;
fluidLocker = false;
lockedFluid = null;
times = 1;
}
if (ticker > 100000000) ticker = 0;
if (ticker > 3 * 17 * 19 * 1000000) ticker = 0;
return true;
}

Expand Down Expand Up @@ -326,7 +365,8 @@ public String[] getDescription() {
.addInfo("Controller block for the Naquadah Reactor")
.addInfo("Environmental Friendly!")
.addInfo("Generate power with the High-energy molten metal.")
.addInfo("Input liquid nuclear fuel ,molten enriched naquadah or naquadria.")
.addInfo("Input liquid nuclear fuel, molten enriched naquadah or naquadria.")
.addInfo("The reactor will explode when there are more than ONE types of fuel in the hatch!")
.addInfo("Consume coolant 50mb/t to increase the efficiency:")
.addInfo("IC2 Coolant 105%, Super Coolant 150%, Cryotheum 275%")
.addInfo("Consume excited liquid to increase the output power:")
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/GoodGenerator/Loader/RecipeLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static void RecipeLoad(){
ItemList.Field_Generator_ZPM.get(2),
ItemList.Electric_Pump_UV.get(2),
GT_OreDictUnificator.get(OrePrefixes.circuit,Materials.Infinite,2),
GT_OreDictUnificator.get(OrePrefixes.cableGt08,Materials.Tungsten,8),
GT_OreDictUnificator.get(OrePrefixes.wireGt08,Materials.SuperconductorUV,8),
GT_OreDictUnificator.get(OrePrefixes.pipeHuge,Materials.Lead,4),
GT_OreDictUnificator.get(OrePrefixes.plate,Materials.NaquadahAlloy,8),
GT_OreDictUnificator.get(OrePrefixes.screw,Materials.Osmium,16)
Expand Down

0 comments on commit 9a06a9f

Please sign in to comment.