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

Commit

Permalink
Remove explosion possibility
Browse files Browse the repository at this point in the history
- Removed doExplosion from the EU generation part of the cody, now the machine only stops when the dynamo is full;
- Renamed variables and changed comments and tooltip to match the way the code works now.
  • Loading branch information
Steelux8 committed May 19, 2024
1 parent 21e0b38 commit 56344ce
Showing 1 changed file with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ public class UniversalChemicalFuelEngine extends GT_MetaTileEntity_TooltipMultiB
protected final double GAS_EFFICIENCY_COEFFICIENT = 0.04D;
protected final double ROCKET_EFFICIENCY_COEFFICIENT = 0.005D;
protected final double EFFICIENCY_CEILING = 1.5D;
protected final int EXPLOSION_SAFETY_TIMER = 200;
protected final int HEATING_TIMER = 200;

private long tEff;
private int explosionSafetyTicks;
private boolean isExplosionSafe;
private int heatingTicks;
private boolean isStoppingSafe;

private IStructureDefinition<UniversalChemicalFuelEngine> multiDefinition = null;

Expand Down Expand Up @@ -187,9 +187,9 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() {
.addInfo("BURNING BURNING BURNING").addInfo("Use combustible liquid to generate power.")
.addInfo("You need to supply Combustion Promoter to keep it running.")
.addInfo("It will consume all the fuel and promoter in the hatch every second.")
.addInfo("If the energy hatch's buffer fills up, the machine will explode!")
.addInfo("When turned on, there's 10-second starting period which prevents explosions.")
.addInfo("Even if an explosion is prevented, all the fuel in the hatch will be voided.")
.addInfo("If the Dynamo Hatch's buffer fills up, the machine will stop.")
.addInfo("When turned on, there's 10-second period where the machine will not stop.")
.addInfo("Even if it doesn't stop, all the fuel in the hatch will be consumed.")
.addInfo("The efficiency is determined by the proportion of Combustion Promoter to fuel.")
.addInfo("The proportion is bigger, and the efficiency will be higher.")
.addInfo("Start machine with power button to force structure check.")
Expand Down Expand Up @@ -252,20 +252,21 @@ protected CheckRecipeResult processFuel(ArrayList<FluidStack> tFluids, RecipeMap

@Override
public void stopMachine() {
// Reset the counter for explosion safety, so that it works again when the machine restarts
explosionSafetyTicks = 0;
// Reset the counter for heating, so that it works again when the machine restarts
heatingTicks = 0;
super.stopMachine();
}

@Override
public boolean onRunningTick(ItemStack stack) {
super.onRunningTick(stack);
// Counts ticks up to the defined timer (200 ticks, 10 seconds)
// The multiblock will not explode due to excess energy during this time
if (explosionSafetyTicks < EXPLOSION_SAFETY_TIMER) {
explosionSafetyTicks++;
isExplosionSafe = true;
} else if (isExplosionSafe) isExplosionSafe = false;
// The multiblock will not stop due to excess energy during this time
// Machine used to explode in the past, this timer was first made to prevent that
if (heatingTicks < HEATING_TIMER) {
heatingTicks++;
isStoppingSafe = true;
} else if (isStoppingSafe) isStoppingSafe = false;

if (this.getBaseMetaTileEntity().isServerSide()) {
addAutoEnergy();
Expand Down Expand Up @@ -297,17 +298,15 @@ void addAutoEnergy() {
GT_MetaTileEntity_Hatch_Dynamo tHatch = mDynamoHatches.get(0);
if (tHatch.maxEUOutput() * tHatch.maxAmperesOut() >= exEU) {
tHatch.setEUVar(Math.min(tHatch.maxEUStore(), tHatch.getBaseMetaTileEntity().getStoredEU() + exEU));
} else if (!isExplosionSafe) {
tHatch.doExplosion(tHatch.maxEUOutput());
} else if (!isStoppingSafe) {
stopMachine();
}
}
if (!eDynamoMulti.isEmpty()) {
GT_MetaTileEntity_Hatch_DynamoMulti tHatch = eDynamoMulti.get(0);
if (tHatch.maxEUOutput() * tHatch.maxAmperesOut() >= exEU) {
tHatch.setEUVar(Math.min(tHatch.maxEUStore(), tHatch.getBaseMetaTileEntity().getStoredEU() + exEU));
} else if (!isExplosionSafe) {
tHatch.doExplosion(tHatch.maxEUOutput());
} else if (!isStoppingSafe) {
stopMachine();
}
}
Expand Down

0 comments on commit 56344ce

Please sign in to comment.