Merge pull request #142 from pyure/patch-1

Heat Exchanger updates
This commit is contained in:
Blood-Asp 2015-08-15 21:50:37 +02:00
commit 2892a32022

View file

@ -82,73 +82,92 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBloc
return aFacing > 1;
}
public boolean checkRecipe(ItemStack aStack)
{
if(GT_ModHandler.isLava(mInputHotFluidHatch.getFluid())){
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);
this.mMaxProgresstime = 20;
this.mEUt = fluidAmount*4;
this.mEfficiencyIncrease = 80;
return true;
}
if(mInputHotFluidHatch.getFluid().isFluidEqual(FluidRegistry.getFluidStack("ic2hotcoolant", 1))){
int fluidAmount = mInputHotFluidHatch.getFluidAmount();
if(fluidAmount >= 4000){superheated=true;}else{superheated=false;}
if(fluidAmount>8000){fluidAmount=8000;}
mInputHotFluidHatch.drain(fluidAmount, true);
mOutputColdFluidHatch.fill(FluidRegistry.getFluidStack("ic2coolant", fluidAmount), true);
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) {
public boolean checkRecipe(ItemStack aStack) {
if (mInputHotFluidHatch.getFluid() == null)
return true;
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 fluidAmountToConsume = mInputHotFluidHatch.getFluidAmount(); // how much fluid is in hatch
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
int superheated_threshold = 4000; // default: must have 4000L per second to generate superheated steam
float efficiency = 1f; // default: operate at 100% efficiency with no integrated circuitry
float penalty_per_config = 0.015f; // penalize 1.5% efficiency per circuitry level (1-25)
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;
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
// Do we have an integrated circuit with a valid configuration?
if (mInventory[1] != null && mInventory[1].getUnlocalizedName().startsWith("gt.integrated_circuit")) {
int circuit_config = mInventory[1].getItemDamage();
if (circuit_config >= 1 && circuit_config <= 25) {
// If so, apply the penalty and reduced threshold.
penalty = (circuit_config - 1) * penalty_per_config;
superheated_threshold -= (shs_reduction_per_config * (circuit_config - 1));
}
}
}
return true;
efficiency -= penalty;
// 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;
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack)
{