diff --git a/src/dark/api/energy/ExtraBlockData.java b/src/dark/api/energy/ExtraBlockData.java index 1b613b4d..815dc86a 100644 --- a/src/dark/api/energy/ExtraBlockData.java +++ b/src/dark/api/energy/ExtraBlockData.java @@ -7,9 +7,9 @@ import universalelectricity.core.vector.Vector3; import com.builtbroken.common.Pair; -/** Information about block not provided by minecraft such as density, mass, volume, tempature, etc +/** Information about blocks not provided by minecraft such as density, mass, volume, heating values, chemical properties, etc * etc - * + * * @author DarkGuardsman */ public class ExtraBlockData { diff --git a/src/dark/api/energy/IHeatObject.java b/src/dark/api/energy/IHeatObject.java index 18d615ec..ea4bcad8 100644 --- a/src/dark/api/energy/IHeatObject.java +++ b/src/dark/api/energy/IHeatObject.java @@ -1,23 +1,27 @@ package dark.api.energy; +import dark.api.parts.ITileConnector; import net.minecraftforge.common.ForgeDirection; /** Used by TileEntities or Entities to show heat stored and cooling rate of the object - * + * * @author DarkGuardsman */ -public interface IHeatObject +public interface IHeatObject extends ITileConnector { - /** Amount of heat stored in the body of the object - * + + /** Amount of heat stored in the body of the object. Think of it as a battery for heat but + * remember that heat is lost very fast + * * @return amount of heat in generic units */ - public double getHeat(ForgeDirection side); + public float getHeat(ForgeDirection side); /** Sets the heat level of the object or increase it - * + * * @param amount - amount to set or increase by * @param incrase - true if should increase the current heat level */ public void setHeat(double amount, boolean incrase); - /** Rate by which this object can cool by from the given side */ - public double getCoolingRate(ForgeDirection side); + /** Rate by which this object can cool by from the given side. Generally is decided by the blocks + * next to it and the biome the block is in. Is a self heat loss value. */ + public float getCoolingRate(ForgeDirection side); } diff --git a/src/dark/api/energy/IHeatProducer.java b/src/dark/api/energy/IHeatProducer.java deleted file mode 100644 index a0c5d2a1..00000000 --- a/src/dark/api/energy/IHeatProducer.java +++ /dev/null @@ -1,12 +0,0 @@ -package dark.api.energy; - -import net.minecraftforge.common.ForgeDirection; - -public interface IHeatProducer -{ - /** Checks too see if this can produce heat */ - public boolean getCanProduceHeat(ForgeDirection dir); - - /** Gets the amount of heat in joules this can output */ - public float getHeatAmmount(ForgeDirection dir); -} diff --git a/src/dark/api/parts/ITileConnector.java b/src/dark/api/parts/ITileConnector.java index 50af38c7..5aac4eff 100644 --- a/src/dark/api/parts/ITileConnector.java +++ b/src/dark/api/parts/ITileConnector.java @@ -16,6 +16,7 @@ public interface ITileConnector ITEMS(), DATA(), TILE(), - NETWORK(); + NETWORK(), + HEAT(); } } diff --git a/src/dark/core/common/machines/TileEntityHeatCouple.java b/src/dark/core/common/machines/TileEntityHeatCouple.java index 3975cc0c..a155f5c8 100644 --- a/src/dark/core/common/machines/TileEntityHeatCouple.java +++ b/src/dark/core/common/machines/TileEntityHeatCouple.java @@ -5,7 +5,8 @@ import java.util.EnumSet; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; import universalelectricity.core.vector.Vector3; -import dark.api.energy.IHeatProducer; +import dark.api.energy.IHeatObject; +import dark.api.parts.ITileConnector.Connection; import dark.core.prefab.machine.TileEntityEnergyMachine; /** Machine that turns heat into usable electrical energy @@ -16,6 +17,7 @@ public class TileEntityHeatCouple extends TileEntityEnergyMachine protected float tempture = 0.0f; protected float outputWatts = 0f; protected float heatJoules = 0f; + protected float maxHeat = 1000f; @Override public void updateEntity() @@ -30,9 +32,26 @@ public class TileEntityHeatCouple extends TileEntityEnergyMachine { Vector3 loc = new Vector3(this).translate(new Vector3(side)); TileEntity entity = loc.getTileEntity(this.worldObj); - if (entity instanceof IHeatProducer && ((IHeatProducer) entity).getCanProduceHeat(side.getOpposite())) + if (entity instanceof IHeatObject && ((IHeatObject) entity).canTileConnect(Connection.HEAT, side.getOpposite())) { - this.heatJoules = ((IHeatProducer) entity).getHeatAmmount(side.getOpposite()); + if (this.heatJoules < this.maxHeat) + { + float heat = ((IHeatObject) entity).getHeat(side.getOpposite()); + if (heat + heatJoules <= maxHeat) + { + this.heatJoules += heat; + ((IHeatObject) entity).setHeat(-heat, true); + } + else + { + float room = (heat - ((this.heatJoules + heat) - this.maxHeat)); + if (room > 0) + { + this.heatJoules += room; + ((IHeatObject) entity).setHeat(-room, true); + } + } + } } } this.outputWatts = heatJoules * .4f;