Reworked Iron Engine Heat Mechanics

They cool down much faster, but use Coolant while doing so.
Additionally, they are affected by Biome temperature. Expect to need
more water/better Coolant in a desert for optimal operation. Ice Blocks
are also recommended.
This commit is contained in:
CovertJaguar 2013-08-29 07:07:11 -07:00
parent 45e73c28b1
commit 48daafae35
2 changed files with 52 additions and 30 deletions

View file

@ -202,7 +202,7 @@ public class BuildCraftEnergy {
RefineryRecipes.addRecipe(new FluidStack(fluidOil, 1), new FluidStack(fluidFuel, 1), 12, 1); RefineryRecipes.addRecipe(new FluidStack(fluidOil, 1), new FluidStack(fluidFuel, 1), 12, 1);
// Iron Engine Fuels // Iron Engine Fuels
IronEngineFuel.addFuel("lava", 1, 20000); // IronEngineFuel.addFuel("lava", 1, 20000);
IronEngineFuel.addFuel("oil", 3, 20000); IronEngineFuel.addFuel("oil", 3, 20000);
IronEngineFuel.addFuel("fuel", 6, 100000); IronEngineFuel.addFuel("fuel", 6, 100000);

View file

@ -21,6 +21,7 @@ import buildcraft.core.fluids.Tank;
import buildcraft.core.fluids.TankManager; import buildcraft.core.fluids.TankManager;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.Utils; import buildcraft.core.utils.Utils;
import static buildcraft.energy.TileEngine.MIN_HEAT;
import buildcraft.energy.gui.ContainerEngine; import buildcraft.energy.gui.ContainerEngine;
import java.util.LinkedList; import java.util.LinkedList;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -29,6 +30,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry;
@ -40,7 +42,8 @@ public class TileEngineIron extends TileEngine implements IFluidHandler {
public static int MAX_LIQUID = FluidContainerRegistry.BUCKET_VOLUME * 10; public static int MAX_LIQUID = FluidContainerRegistry.BUCKET_VOLUME * 10;
public static float HEAT_PER_MJ = 0.0023F; public static float HEAT_PER_MJ = 0.0023F;
public static float COOLDOWN_RATE = 0.01F; public static float COOLDOWN_RATE = 0.05F;
public static float MAX_COOLING = 0.1F;
int burnTime = 0; int burnTime = 0;
private Tank tankFuel; private Tank tankFuel;
private Tank tankCoolant; private Tank tankCoolant;
@ -48,11 +51,12 @@ public class TileEngineIron extends TileEngine implements IFluidHandler {
private Fuel currentFuel = null; private Fuel currentFuel = null;
public int penaltyCooling = 0; public int penaltyCooling = 0;
boolean lastPowered = false; boolean lastPowered = false;
private BiomeGenBase biomeCache;
public TileEngineIron() { public TileEngineIron() {
super(1); super(1);
tankFuel = new Tank("tankFuel", MAX_LIQUID); tankFuel = new Tank("tankFuel", MAX_LIQUID);
tankCoolant = new Tank("tankCoolant",MAX_LIQUID); tankCoolant = new Tank("tankCoolant", MAX_LIQUID);
tankManager.add(tankFuel); tankManager.add(tankFuel);
tankManager.add(tankCoolant); tankManager.add(tankCoolant);
} }
@ -111,6 +115,21 @@ public class TileEngineIron extends TileEngine implements IFluidHandler {
} }
} }
private float getBiomeTempScalar() {
if (biomeCache == null)
biomeCache = worldObj.getBiomeGenForCoords(xCoord, zCoord);
float tempScalar = biomeCache.temperature - 1.0F;
tempScalar *= 0.5F;
tempScalar += 1.0F;
return tempScalar;
}
@Override
public void invalidate() {
super.invalidate();
biomeCache = null;
}
@Override @Override
public boolean isBurning() { public boolean isBurning() {
FluidStack fuel = tankFuel.getFluid(); FluidStack fuel = tankFuel.getFluid();
@ -148,13 +167,13 @@ public class TileEngineIron extends TileEngine implements IFluidHandler {
} }
currentOutput = currentFuel.powerPerCycle; // Comment out for constant power currentOutput = currentFuel.powerPerCycle; // Comment out for constant power
addEnergy(currentFuel.powerPerCycle); addEnergy(currentFuel.powerPerCycle);
heat += currentFuel.powerPerCycle * HEAT_PER_MJ; heat += currentFuel.powerPerCycle * HEAT_PER_MJ * getBiomeTempScalar();
} }
} else if (penaltyCooling <= 0) { } else if (penaltyCooling <= 0) {
if (lastPowered) { if (lastPowered) {
lastPowered = false; lastPowered = false;
penaltyCooling = 30 * 20; penaltyCooling = 10;
// 30 sec of penalty on top of the cooling // 10 tick of penalty on top of the cooling
} }
} }
} }
@ -169,7 +188,7 @@ public class TileEngineIron extends TileEngine implements IFluidHandler {
final ItemStack stack = getStackInSlot(0); final ItemStack stack = getStackInSlot(0);
if (stack != null) { if (stack != null) {
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack); FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack);
if (liquid == null && heat > IDEAL_HEAT) { if (liquid == null && heat > MIN_HEAT * 2) {
liquid = IronEngineCoolant.getFluidCoolant(stack); liquid = IronEngineCoolant.getFluidCoolant(stack);
} }
@ -181,34 +200,37 @@ public class TileEngineIron extends TileEngine implements IFluidHandler {
} }
} }
if (heat > IDEAL_HEAT) {
float extraHeat = heat - IDEAL_HEAT;
FluidStack coolant = this.tankCoolant.getFluid();
Coolant currentCoolant = IronEngineCoolant.getCoolant(coolant);
if (currentCoolant != null) {
float cooling = currentCoolant.getDegreesCoolingPerMB(heat);
if (coolant.amount * cooling > extraHeat) {
coolant.amount -= Math.round(extraHeat / cooling);
heat = IDEAL_HEAT;
} else {
heat -= coolant.amount * cooling;
tankCoolant.setFluid(null);
}
}
}
if (heat > MIN_HEAT && (penaltyCooling > 0 || !isRedstonePowered)) { if (heat > MIN_HEAT && (penaltyCooling > 0 || !isRedstonePowered)) {
heat -= COOLDOWN_RATE; heat -= COOLDOWN_RATE;
coolEngine(MIN_HEAT);
getEnergyStage();
} else if (heat > IDEAL_HEAT) {
coolEngine(IDEAL_HEAT);
} }
if (heat <= MIN_HEAT) { if (heat <= MIN_HEAT && penaltyCooling > 0)
heat = MIN_HEAT;
}
if (heat <= MIN_HEAT && penaltyCooling > 0) {
penaltyCooling--; penaltyCooling--;
if (heat <= MIN_HEAT)
heat = MIN_HEAT;
}
private void coolEngine(float idealHeat) {
float extraHeat = heat - idealHeat;
extraHeat = Math.min(MAX_COOLING, extraHeat);
FluidStack coolant = this.tankCoolant.getFluid();
Coolant currentCoolant = IronEngineCoolant.getCoolant(coolant);
if (currentCoolant != null) {
float cooling = currentCoolant.getDegreesCoolingPerMB(heat);
cooling /= getBiomeTempScalar();
if (coolant.amount * cooling > extraHeat) {
coolant.amount -= Math.round(extraHeat / cooling);
heat -= extraHeat;
} else {
heat -= coolant.amount * cooling;
tankCoolant.setFluid(null);
}
} }
} }