From c87c50390fb9165f201bd5b9fbc0ffa073e81e5d Mon Sep 17 00:00:00 2001 From: Calclavia Date: Mon, 17 Mar 2014 20:02:30 +0800 Subject: [PATCH] Gutters placed above firebox can now boil water --- .../archaic/firebox/TileFirebox.java | 36 ++++++++++++++----- .../archaic/fluid/gutter/TileGutter.java | 2 +- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/archaic/src/main/java/resonantinduction/archaic/firebox/TileFirebox.java b/archaic/src/main/java/resonantinduction/archaic/firebox/TileFirebox.java index 1c1bc5d95..1c6a23cfc 100644 --- a/archaic/src/main/java/resonantinduction/archaic/firebox/TileFirebox.java +++ b/archaic/src/main/java/resonantinduction/archaic/firebox/TileFirebox.java @@ -16,6 +16,8 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; +import resonantinduction.archaic.Archaic; +import resonantinduction.archaic.fluid.gutter.TileGutter; import resonantinduction.core.ResonantInduction; import resonantinduction.core.resource.ResourceGenerator; import resonantinduction.core.resource.TileMaterial; @@ -69,7 +71,7 @@ public class TileFirebox extends TileElectricalInventory implements IPacketRecei */ FluidStack drainFluid = tank.drain(FluidContainerRegistry.BUCKET_VOLUME, false); - if (drainFluid != null && drainFluid.amount == FluidContainerRegistry.BUCKET_VOLUME) + if (drainFluid != null && drainFluid.amount == FluidContainerRegistry.BUCKET_VOLUME && drainFluid.fluidID == FluidRegistry.LAVA.getID()) { if (burnTime == 0) { @@ -89,7 +91,7 @@ public class TileFirebox extends TileElectricalInventory implements IPacketRecei burnTime += 2; } - else if (canBurn(this.getStackInSlot(0))) + else if (canBurn(getStackInSlot(0))) { if (burnTime == 0) { @@ -163,6 +165,26 @@ public class TileFirebox extends TileElectricalInventory implements IPacketRecei heatEnergy = 0; } } + else if (blockID == Archaic.blockGutter.blockID) + { + TileEntity tileEntity = worldObj.getBlockTileEntity(xCoord, yCoord + 1, zCoord); + + if (tileEntity instanceof TileGutter) + { + usedHeat = true; + int volume = Math.min(((TileGutter) tileEntity).getInternalTank().getFluidAmount(), 10); + if (volume > 0 && heatEnergy >= getRequiredBoilWaterEnergy(volume)) + { + if (FluidRegistry.getFluid("steam") != null) + { + MinecraftForge.EVENT_BUS.post(new BoilEvent(worldObj, new Vector3(this).translate(0, 1, 0), new FluidStack(FluidRegistry.WATER, volume), new FluidStack(FluidRegistry.getFluid("steam"), volume), 2)); + ((TileGutter) tileEntity).drain(ForgeDirection.DOWN, volume, true); + } + + heatEnergy = 0; + } + } + } if (!usedHeat) { @@ -191,16 +213,14 @@ public class TileFirebox extends TileElectricalInventory implements IPacketRecei */ public long getRequiredBoilWaterEnergy(int volume) { - int temperatureChange = 373 - ThermalPhysics.getTemperatureForCoordinate(worldObj, xCoord, zCoord); - int mass = ThermalPhysics.getMass(volume, 1); - return ThermalPhysics.getEnergyForTemperatureChange(mass, 4200, temperatureChange) + ThermalPhysics.getEnergyForStateChange(mass, 2257000); + return (long) ThermalPhysics.getRequiredBoilWaterEnergy(worldObj, xCoord, zCoord, volume); } public long getMeltIronEnergy(float volume) { - int temperatureChange = 1811 - ThermalPhysics.getTemperatureForCoordinate(worldObj, xCoord, zCoord); - int mass = ThermalPhysics.getMass(volume, 7.9f); - return ThermalPhysics.getEnergyForTemperatureChange(mass, 450, temperatureChange) + ThermalPhysics.getEnergyForStateChange(mass, 272000); + float temperatureChange = 1811 - ThermalPhysics.getTemperatureForCoordinate(worldObj, xCoord, zCoord); + float mass = ThermalPhysics.getMass(volume, 7.9f); + return (long) (ThermalPhysics.getEnergyForTemperatureChange(mass, 450, temperatureChange) + ThermalPhysics.getEnergyForStateChange(mass, 272000)); } @Override diff --git a/archaic/src/main/java/resonantinduction/archaic/fluid/gutter/TileGutter.java b/archaic/src/main/java/resonantinduction/archaic/fluid/gutter/TileGutter.java index fccbe53d7..acb1a6e36 100644 --- a/archaic/src/main/java/resonantinduction/archaic/fluid/gutter/TileGutter.java +++ b/archaic/src/main/java/resonantinduction/archaic/fluid/gutter/TileGutter.java @@ -53,7 +53,7 @@ public class TileGutter extends TilePressureNode { public TileGutter() { - super(Material.wood); + super(Material.rock); textureName = "material_wood_surface"; isOpaqueCube = false; normalRender = false;