aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlood-Asp <bloodasphendrik@gmail.com>2015-08-15 21:50:37 +0200
committerBlood-Asp <bloodasphendrik@gmail.com>2015-08-15 21:50:37 +0200
commit2892a32022a160f7de64c041c4ad92effd69cf93 (patch)
tree3a28b6fdc3902ff0fa5f0e801767a365aea095c2
parent0341ae67ef7e0f177fecc4e16522e34f80e17842 (diff)
parent2f340097b969aaff6aeb9ba919d3c321722c1d8c (diff)
downloadGT5-Unofficial-2892a32022a160f7de64c041c4ad92effd69cf93.tar.gz
GT5-Unofficial-2892a32022a160f7de64c041c4ad92effd69cf93.tar.bz2
GT5-Unofficial-2892a32022a160f7de64c041c4ad92effd69cf93.zip
Merge pull request #142 from pyure/patch-1
Heat Exchanger updates
-rw-r--r--main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java139
1 files changed, 79 insertions, 60 deletions
diff --git a/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java b/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java
index 30ee99fed5..3a6a51fa46 100644
--- a/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java
+++ b/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java
@@ -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;}
+ public boolean checkRecipe(ItemStack aStack) {
+ if (mInputHotFluidHatch.getFluid() == null)
+ return true;
+
+ int fluidAmountToConsume = mInputHotFluidHatch.getFluidAmount(); // how much fluid is in hatch
+
+ 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;
+
+ // 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));
+ }
+ }
+ 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;
- }
+ 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 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 (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
+ 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
+ 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
+ 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;
}
- return true;
- }
private static boolean controller;
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack)
{