Heat Exchanger updates

* Can now adjust the minimum threshold for Superheated steam via Integrated Circuits inside the LHE

* Restored full useWater reliance
* HotCoolant now increases efficiency at same rate as lava (80 instead of 20, feel free to revert)
* Please double-check math on Lava output.
This commit is contained in:
pyure 2015-08-14 23:56:36 -04:00
parent 0341ae67ef
commit 2f340097b9

View file

@ -82,73 +82,92 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBloc
return aFacing > 1; return aFacing > 1;
} }
public boolean checkRecipe(ItemStack aStack) public boolean checkRecipe(ItemStack aStack) {
{ if (mInputHotFluidHatch.getFluid() == null)
if(GT_ModHandler.isLava(mInputHotFluidHatch.getFluid())){ return true;
int fluidAmount = mInputHotFluidHatch.getFluidAmount();
if(fluidAmount >= 500){superheated=true;}else{superheated=false;}
if(fluidAmount>1000){fluidAmount=1000;}
mInputHotFluidHatch.drain(fluidAmount, true);
mOutputColdFluidHatch.fill(FluidRegistry.getFluidStack("ic2pahoehoelava", fluidAmount), true);
int fluidAmountToConsume = mInputHotFluidHatch.getFluidAmount(); // how much fluid is in hatch
this.mMaxProgresstime = 20; int superheated_threshold = 4000; // default: must have 4000L per second to generate superheated steam
this.mEUt = fluidAmount*4; float efficiency = 1f; // default: operate at 100% efficiency with no integrated circuitry
this.mEfficiencyIncrease = 80; float penalty_per_config = 0.015f; // penalize 1.5% efficiency per circuitry level (1-25)
return true; int shs_reduction_per_config = 150; // reduce threshold 150L/s per circuitry level (1-25)
} float steam_output_multiplier = 4f; // default: multiply output by 4
float penalty = 0.0f; // penalty to apply to output based on circuitry level (1-25).
boolean do_lava = false;
if(mInputHotFluidHatch.getFluid().isFluidEqual(FluidRegistry.getFluidStack("ic2hotcoolant", 1))){ // Do we have an integrated circuit with a valid configuration?
int fluidAmount = mInputHotFluidHatch.getFluidAmount(); if (mInventory[1] != null && mInventory[1].getUnlocalizedName().startsWith("gt.integrated_circuit")) {
if(fluidAmount >= 4000){superheated=true;}else{superheated=false;} int circuit_config = mInventory[1].getItemDamage();
if(fluidAmount>8000){fluidAmount=8000;} if (circuit_config >= 1 && circuit_config <= 25) {
mInputHotFluidHatch.drain(fluidAmount, true); // If so, apply the penalty and reduced threshold.
mOutputColdFluidHatch.fill(FluidRegistry.getFluidStack("ic2coolant", fluidAmount), true); penalty = (circuit_config - 1) * penalty_per_config;
superheated_threshold -= (shs_reduction_per_config * (circuit_config - 1));
}
this.mMaxProgresstime = 20;
this.mEUt = fluidAmount/2;
this.mEfficiencyIncrease = 20;
return true;
}
return false;}
private float water;
private int useWater(float input){
water = water + input;
int usage = (int)water;
water = water - (int)usage;
return usage;
}
public boolean onRunningTick(ItemStack aStack) {
if (this.mEUt > 0) {
int tGeneratedEU = (int) (this.mEUt * 2L * this.mEfficiency / 10000L); // APPROXIMATELY how much steam to generate.
if (tGeneratedEU > 0) {
if (superheated)
tGeneratedEU /= 2; // We produce half as much superheated steam if necessary
int distilledConsumed = useWater(tGeneratedEU / 160f); // how much distilled water to consume
tGeneratedEU = distilledConsumed * 160; // EXACTLY how much steam to generate, producing a perfect 1:160 ratio with distilled water consumption
FluidStack distilledStack = GT_ModHandler.getDistilledWater(distilledConsumed);
if (depleteInput(distilledStack)) // Consume the distilled water
{
if (superheated) {
addOutput(FluidRegistry.getFluidStack("ic2superheatedsteam", tGeneratedEU)); // Generate superheated steam
} else {
addOutput(GT_ModHandler.getSteam(tGeneratedEU)); // Generate regular steam
}
} else {
explodeMultiblock(); // Generate crater
} }
} efficiency -= penalty;
return true;
// If we're working with lava, adjust the threshold and multipliers accordingly.
if (GT_ModHandler.isLava(mInputHotFluidHatch.getFluid())) {
superheated_threshold /= 4;
do_lava = true;
} else if (mInputHotFluidHatch.getFluid().isFluidEqual(FluidRegistry.getFluidStack("ic2hotcoolant", 1))) {
steam_output_multiplier = 0.5f;
} else {
// If we're working with neither, fail out
return false;
}
superheated = fluidAmountToConsume >= superheated_threshold; // set the internal superheated flag if we have enough hot fluid. Used in the onRunningTick method.
fluidAmountToConsume = Math.min(fluidAmountToConsume, superheated_threshold * 2); // Don't consume too much hot fluid per second
mInputHotFluidHatch.drain(fluidAmountToConsume, true);
this.mMaxProgresstime = 20;
this.mEUt = (int) (fluidAmountToConsume * steam_output_multiplier * efficiency);
if (do_lava) {
mOutputColdFluidHatch.fill(FluidRegistry.getFluidStack("ic2pahoehoelava", fluidAmountToConsume), true);
this.mEfficiencyIncrease = 80;
} else {
mOutputColdFluidHatch.fill(FluidRegistry.getFluidStack("ic2coolant", fluidAmountToConsume), true);
this.mEfficiencyIncrease = 80;
}
return true;
}
private float water;
private int useWater(float input) {
water = water + input;
int usage = (int) water;
water = water - (int) usage;
return usage;
}
public boolean onRunningTick(ItemStack aStack) {
if (this.mEUt > 0) {
int tGeneratedEU = (int) (this.mEUt * 2L * this.mEfficiency / 10000L); // APPROXIMATELY how much steam to generate.
if (tGeneratedEU > 0) {
if (superheated)
tGeneratedEU /= 2; // We produce half as much superheated steam if necessary
int distilledConsumed = useWater(tGeneratedEU / 160f); // how much distilled water to consume
//tGeneratedEU = distilledConsumed * 160; // EXACTLY how much steam to generate, producing a perfect 1:160 ratio with distilled water consumption
FluidStack distilledStack = GT_ModHandler.getDistilledWater(distilledConsumed);
if (depleteInput(distilledStack)) // Consume the distilled water
{
if (superheated) {
addOutput(FluidRegistry.getFluidStack("ic2superheatedsteam", tGeneratedEU)); // Generate superheated steam
} else {
addOutput(GT_ModHandler.getSteam(tGeneratedEU)); // Generate regular steam
}
} else {
explodeMultiblock(); // Generate crater
}
}
return true;
}
return true;
} }
return true;
}
private static boolean controller; private static boolean controller;
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack)
{ {